Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Value inside model don't change value with server script on touched event ?

Asked by 3 years ago

I made a server script where if the model touches the crowbar part named "touch", a value inside of it named "Prisoner" will changed to true or false depending on if it's already false or true :


local debounce = false local debounce_delay = 1 local part = script.Parent.Touch part.Touched:Connect(function(hit) if not debounce then debounce = true if hit ~= nil then if hit.Parent then if hit.Parent.Name == "Dummy" then print("It's dummy") local player = hit.Parent if player:FindFirstChild("Prisoner") then local Prisoner = player.Prisoner if Prisoner:IsA("BoolValue") then if Prisoner.Value == true then Prisoner.Value = false print("Changed to false") elseif Prisoner.Value == false then Prisoner.Value = true print("Changed to true") end end end end end end wait(debounce_delay) debounce = false end end)

The model is named "Dummy" and is inside the workspace

1 answer

Log in to vote
0
Answered by
Ludzik78 136
3 years ago

Cause your asking if hit.Parent.Name is a Dummy, then asking for the player. Thats why it doesnt work.

Ad

Answer this question