[subject deleted]
[subject deleted]
try to print out sth in that script, so u can check if it even runs
If you’re using a BoolValue for Enabled, then you need to use the value of that. Since you’re not checking or changing the actual value of it you’re just checking if the object exists and anytime you try to change it, it will not bother. A simple fix would be to simply change the third line of your code to
local enabled = button.Enabled.Value
You’re setting enabled to false and then running this:
So it makes them able to jump. Is this intended?
Quick question, is Enabled a bool value? And like the post below me, I don’t define properties as a variable. Just set button.Enabled to false instead of creating a whole separate variable for it.
You’re setting the value of enabled at first to the value of button.Enabled. Then, in your code, you change enabled to true/false, instead of changing the actual button.Enabled property. To combat this, do not define properties inside your variables.
change this to
local button = script.Parent.Button
see if that works
Your code will actually set JumpPower to 50, when the button is enabled. After it is enabled, you set it to disabled and then you run another function that checks if it is enabled; if it is not, then it sets JumpPower to 50.
I think properties are passed by reference, so changing enabled would change the original value, and changing the original value would change enabled.
They are not, using button.Enabled will give you the value of button.Enabled, not a reference to it.
local seat = script.Parent
local button = script.Parent.Button
local enabled = button.Enabled
local clicker = button.ClickDetector
function onSit()
if enabled.Value == true then --a boolvalue has to be indexed by .Value
if seat.Occupant then
seat.Occupant.JumpPower = 0
end
end
if enabled.Value == false then
if seat.Occupant then
seat.Occupant.JumpPower = 50
end
end
end
function onClick()
if enabled.Value == true then
enabled = false
button.BrickColor = ("Really Red")
onSit()
elseif enabled.Value == false then
enabled = true
button.BrickColor = ("Lime Green")
onSit()
end
end
clicker.MouseClick:Connect(onClick)
I just checked that, and it seems like you are right, I will like your post because it is a possible solution