I've looked all over devforum but can't seem to find an answer. Does anybody maybe know why this doesn't want to be detected?
local plr = nil local part = script.Parent local position1 = script.Parent.Parent.Move2.Position local value = part.Parent.NextMove.Value part.Touched:Connect(function(player) plr = player end) part.TouchEnded:Connect(function() plr = nil end) --Detect Value Changed and move the player value.Changed:Connect(function() print("Detected") plr.Parent.Humanoid:MoveTo(position1) end)
This is hard to debug for me because you have gave little information about the problem, okay it is not working, are there any errors in the output? If yes then post them everytime when making question because this is how you should debug your code.
My answer won't be accurate but i assume that
local value = part.Parent.NextMove.Value
Here, NextMove is BoolValue Instance inside of some parent and .Value is it's value, which is boolean, if it is true then you've got an error which says: Attempt to index boolean with Changed
. The reason why this is happening because value variable stands for NextMove's value which is true or false and Changed cannot be called on script values (Script values are those that can't be seen in workspace, by that i mean all values inside of a script like: v = 5, v = true, v = "string"
, these are script values). Changed is event of all instances so what you should do is set the variable to the BoolValue instance
local value = part.Parent.NextMove
and call changed on it
value.Changed:Connect(function() -- la la la end)
But this won't work if local value = part.Parent.NextMove.Value
is an instance and not value