I have the following script here, where there is a basepart "Push"
ts = game:GetService("TweenService") ti = TweenInfo.new(3) push = script.Parent.Parent.push weighted = {} weighted.CFrame = script.Parent.Parent.push.CFrame+Vector3.new(0,10,0) left = {} left.CFrame = script.Parent.Parent.push.CFrame stepped = ts:Create(push,ti,weighted) unstepped = ts:Create(push,ti,left) script.Parent.Touched:connect(function(a) if a.Parent:FindFirstChild("Humanoid") or a.Parent.Name == "block" then stepped:Play() end end) script.Parent.TouchEnded:connect(function(a) if a.Parent:FindFirstChild("Humanoid") or a.Parent.Name == "block" then unstepped:Play() end end)
So the problem here is that in the script I want whenever a character or a model named "block" stop touching the block to play the animation "unstepped".
So here is the problem, I tried to let a model named "block" touch the block, but the animation doesn't play.
I think the issue here is that the returning object from ".touched" and ".touchended" is changing through more than one objects. Which is why the animation acts as if it is switching between two animations.
How could I fix this?
Alternatively, how do I make a weight activated button?
Ok, so touchEnded is not how you want to go. It's just checking if a part stops touching it, which is not how to check if a player has left a certain area. For that, use:
local region = --enter region here local inRegion = game.Workspace:FindPartsInRegion3WithWhitelist(char)
if the character is in the region inRegion will be a table with parts, else it will contain a empty table.
TouchEnded is only for scenarios were you have one part thats moving at a constant velocity, not for multiple.