Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't this script toggle when I press a button?

Litterally nothing in this script works and the script runs. Even though it says "game.ServerScriptServerice.Blood = false" it does nothing. I need help.

game.ServerScriptService.Blood = false

local parent = script.Parent

local function on()
game.ServerScriptService.Blood = true

end

local function off()
game.ServerScriptService.Blood = false

end

local function OnClicked()
if game.ServerScriptService.Blood == true then off() else on() end

	print ("Blood Toggled")
end
parent.MouseButton1Click:connect(OnClicked)

So can someone tell me what's wrong? It's probably obvious but i'm a noob.

Thank you.

2 answers

✓ Accepted answer

I assume that the game.ServerScriptStorage.Blood is a script, so you would want to have it so that it says game.ServerScriptStorage.Blood.Disabled.

This should be a working script:

game.ServerScriptService.Blood.Disabled = true

local parent = script.Parent

local function on()
game.ServerScriptService.Blood.Disabled = false

end

local function off()
game.ServerScriptService.Blood.Disabled = true

end

local function OnClicked()
if game.ServerScriptService.Blood.Disabled == true then off() else on() end

    print ("Blood Toggled")
end
parent.MouseButton1Click:connect(OnClicked)

If you have any questions, please ask.

3 comments

0

Thank you.

0

No problem! Happy to help! :D

0

ServerScriptService is inaccessible by clients.

local s = game.ServerScriptService.Blood
s.Disabled = true
script.Parent.MouseButton1Click:Connect(function()
 print ("Blood Toggled")
if s.Disabled == true then
s.Disabled = false 
else 
s.Disabled = true
end
end)

This is the short Version of the working script :)

2 comments

0

No, s is not a reference to the property, it is a reference to the current value of the Disabled property. If the Disabled property changes, the variable doesn't update.

0

?

This discussion is preserved as it was. New answers, comments, and votes are closed.