Log in to vote

How do I I make this script with the "touchended" work?

Asked by 3 years ago
Edited 3 years ago

I have the following script here, where there is a basepart "Push"

ts = game:GetService("TweenService")
ti =
push = script.Parent.Parent.push
weighted = {}
weighted.CFrame =,10,0)
left = {}
left.CFrame = script.Parent.Parent.push.CFrame
stepped = ts:Create(push,ti,weighted)
unstepped = ts:Create(push,ti,left)

    if a.Parent:FindFirstChild("Humanoid") or a.Parent.Name == "block" then 

    if a.Parent:FindFirstChild("Humanoid") or a.Parent.Name == "block" then 

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?

1 answer

Log in to vote
Answered by 3 years ago

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.

I'm having a hard time grasping how I could use that method to get my intended results. guestnot99 112 — 3y

Answer this question