#Button Dont Do Anything
4 messages · Page 1 of 1 (latest)
local EnablePvp = game:GetService("ReplicatedStorage"):WaitForChild("EnablePvp")
local DisablePvp = game:GetService("ReplicatedStorage"):WaitForChild("DisablePvp")
local plr = game.Players.LocalPlayer
local btn = script.Parent
local debounce = false
local CanUse = false
while true do
wait(.01)
local CanPvpEnabled = plr:WaitForChild("CanEnablePvp")
local PvpStatus = plr:WaitForChild("PvpEnabled")
if CanPvpEnabled.Value == false then
btn.Text = "ZONA SEGURA, PVP DESACTIVADO"
btn.BackgroundColor3 = Color3.new(1, 0.333333, 0)
CanUse = false
else
if PvpStatus.Value == true then
btn.Text = "PVP: Activado"
btn.BackgroundColor3 = Color3.new(0.0352941, 0.584314, 0.0980392)
CanUse = true
else
btn.Text = "PVP: Desactivado"
btn.BackgroundColor3 = Color3.new(0.439216, 0, 0)
CanUse = true
end
end
end
btn.MouseButton1Click:Connect(function()
if debounce == false and CanUse == true then
local PvpStatus = plr:WaitForChild("PvpEnabled")
debounce = true
if PvpStatus.Value == false then
btn.Text = "PVP: Activado"
btn.BackgroundColor3 = Color3.new(0.0352941, 0.584314, 0.0980392)
EnablePvp:FireServer(plr)
wait(1)
debounce = false
else
btn.Text = "PVP: Desactivado"
btn.BackgroundColor3 = Color3.new(0.439216, 0, 0)
DisablePvp:FireServer(plr)
wait(1)
debounce = false
end
end
end)
In my place, I created a part, that part when you touch it the variable "CanEnablePvp" goes on true, thats works, but when you click the button InGame, it doesnt happens anything, any changes + any errors...
Here is the ServerScriptService Script:
local EnablePvp = game:GetService("ReplicatedStorage"):WaitForChild("EnablePvp")
local DisablePvp = game:GetService("ReplicatedStorage"):WaitForChild("DisablePvp")
game.Players.PlayerAdded:connect(function(player)
local PvpEnabled = Instance.new("BoolValue")
PvpEnabled.Parent = player
PvpEnabled.Name = "PvpEnabled"
PvpEnabled.Value = false
local CanEnablePvp = Instance.new("BoolValue")
CanEnablePvp.Parent = player
CanEnablePvp.Name = "CanEnablePvp"
CanEnablePvp.Value = false
end)
EnablePvp.OnServerEvent:Connect(function(plr)
local PvpStatus = plr:WaitForChild("PvpEnabled")
PvpStatus.Value = true
end)
DisablePvp.OnServerEvent:Connect(function(plr)
local PvpStatus = plr:WaitForChild("PvpEnabled")
PvpStatus.Value = false
end)