So I'm making a ban hammer that actually bans the player (not really, it's just a kick with a silly message and some creepy music plays inside their head so only they can hear it) but that's not the issue. So I wanted the player to be able to toggle kicking others or not. So, when the player equips the hammer, there is a ban Gui that lets you turn it on and off. Here is the local script:
local lp = game.Players.LocalPlayer local lpc = lp.Character local ON = script.Parent.BanModeToggle.ON local OFF = script.Parent.BanModeToggle.OFF local l = ON.Parent.BanLabel ON.MouseButton1Click:Connect(function() if lpc.BanHammer ~= nil then lpc.BanHammer.Handle.KickRadius.Kick.Disabled = false l.Text = "Ban Mode: ON" end end) OFF.MouseButton1Click:Connect(function() if lpc.BanHammer ~= nil then lpc.BanHammer.Handle.KickRadius.Kick.Disabled = true l.Text = "Ban Mode: OFF" end end)
When viewing on the client, the script disables. But when viewing on the server, the script stays enabled. How can I make the script actually disable? (also, no there is nothing wrong with the kicking script, I've tested it a million times) EDIT: I should also clarify, the text is changing on the script that disables and enables the script plus no errors in the output.
This is because you're only disabling it on the Clients side, this is where a RemoteEvent will come in so we can communicate from Client to Server.
So first, let's make a RemoteEvent in ReplicatedStorage and call it Toggle
Secondly, in the TextButton we'll have a LocalScript that will fire the Event with the following:
local RP = game:GetService("ReplicatedStorage") local Event = RP:WaitForChild("Toggle") -- name of the RemoteEvent local on = true script.Parent.MouseButton1Click:Connect(function() if on == true then on = false script.Parent.Text = "Turned off BanHammer" else on = true script.Parent.Text = "Turned on BanHammer" end Event:FireServer() end)
Finally, we want a Script in ServerScriptService to respond to the Event being fired with the following:
local RP = game:GetService("ReplicatedStorage") local Event = RP:FindFirstChild("Toggle") Event.OnServerEvent:Connect(function(player) local character = player.Character local backpack = player.Backpack if character:FindFirstChild("BanHammer") then --Checks character to see if they're equipping it local Tool = character:FindFirstChild("BanHammer") if not Tool.Script.Disabled then Tool.Script.Disabled = true else Tool.Script.Disabled = false end elseif backpack:FindFirstChild("BanHammer") then --checks backpack to see if they're not equipping it local Tool = backpack:FindFirstChild("BanHammer") if not Tool.Script.Disabled then Tool.Script.Disabled = true else Tool.Script.Disabled = false end end end)
Hopefully, this helps : )
Note: I suggest doing some research on RemoteEvents because they are pretty important.