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

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

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

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

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