Touched Event Not Functioning

I have been trying to make a collapsible part that folds underneath you but the tweening won’t work. There’s no outputs whatsoever.

local TweenService = game:GetService("TweenService")

local TweenInfo = TweenInfo.new(
	1,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.In,
	0,
	false,
	0
)

local Hinge = script.Parent.Parent.PrimaryPart

local Player = game.Players.LocalPlayer

local Characters = {}

table.insert(Characters, Player.Character)

function CollapsePlatform()
	task.wait(1)
	TweenService:Create(Hinge, TweenInfo, {Orientation = Vector3.new(90,0,0)}):Play()
	task.wait(3)
	TweenService:Create(Hinge, TweenInfo, {Orientation = Vector3.new(0,0,0)}):Play()
end 

script.Parent.Touched:Connect(function(Hit)
	print(Hit.Parent)
	if table.find(Characters, Hit.Parent) then
		CollapsePlatform()
	end
end)

TweenService and info variables are in there.

your table.insert isnt complete

1 Like

I completed the table but the touched event doesn’t work. Doesn’t say any errors or anything.

and may I ask whats the point of that condition? cause looking at your code its on a local script and it wouldnt replicate to other players so no need for that condition since itll only affect the local player

1 Like

Precaution I guess, To see if a player is standing on it. Something is wrong with the touching event.

It might be because you did not define the Player correctly. (i might be wrong but small things can take effect on big things)

If that’s not the case then i suspect that you messed up the tween (maybe a typo), did you double check the code?

1 Like

Yes, I have checked everything. I don’t think there’s a typo as no output is generating.

Did you define the PrimaryPart on the model?

1 Like

Yes I did and also welded the parts to the primarypart.

Is the script a LocalScript? if so, i think the problem is that the CollapsePlatform function is a global function instead of a local function.

1 Like

Its a local script and its still doesn’t work doing local function. Thanks for trying to help.

I’m trying my best to find what’s wrong, i’ll send another post if i find something off

1 Like

Wait so if i recall correctly, the tween doesn’t work but it doesn’t send out any errors.

So, here’s my question, is the TouchEvent printing the object? If not then i think you should check there.

1 Like

The touch event doesn’t even run

Wait, is the script parented to the part or is the script parented to the model?, if it’s parented to the model then it makes sense why it doesnt even work because models don’t have a .Touched property

(i realized that local scripts only run on certain spots :skull:)

the script is parented t the part, local scripts works in workspace.

CanTouch isn’t disabled in the parts properties right?
Should be under the CanCollide property.

1 Like

Cantouch is enabled in the parts properties

1 Like

What type of script is it and where is it located?

1 Like

It is located in a model inside a part inside of workspace and its a local script.