Lmao I’m still confused. (30chars)
When you weld an Unanchored Part to an Anchored Part it reacts like an Anchored Part.
He’s suggesting having an Unanchored Part that surrounds your engine (or if it only needs to react to a touch at the front of the engine just locate it at the front) but don’t attach it. Use a BodyPosition or something else to move it with the engine itself and fire the Touched event off that Part.
Is it possible the object the train hits can be unanchored?
An transparent part that has the role of working back-end. It is used for many things including your problem and others.
(I hope this explanation helped)
@Fondatix It’s not hit:FindFirstChild() but hit.Parent:FindFirstChild(). Your Script should look like this:
script.Parent.Touched:Connect(function(hit) print("e") if hit.Parent.Name == "Train" and hit.Parent:FindFirstChild("Moving") then print("a") local explos = Instance.new("Explosion") explos.Position = script.Parent.Position explos.Parent = script.Parent explos.BlastPressure = .4 hit.Parent.Parent.TrainHandler.Disabled = true hit.Parent.Chug:Stop() for i = 20,1,-1 do local End = hit.Parent.Parent:GetPrimaryPartCFrame()*CFrame.Angles(math.rad(90),0,0) local start = hit.Parent.Parent:GetPrimaryPartCFrame() hit.Parent.Parent:SetPrimaryPartCFrame(start:lerp(End,i)) end script.Parent.Explosion:Play() end end)
The Hit is nothing else than the Party that touches it, so if it would be a Player to twist it, then to get his Humanoid he doesn’t have to do
Hit.Parent.Humanoid, because the Part that will touch your Part (and that will cause the
Touched event) will normally be a Player Model’s Child, not the Model itself. To help you you can do this:
script.parent.Touched:Connect(function(hit) print(hit.Parent.Name) end)
it should give you the Name of the Party that touches it, I hope this helped you.
He is not trying to have the player touch it, he wants the train’s part to touch the engine
@Hello42bacon, The Player was just a example.
Models don’t have touch events, I think you mean this:
for i, v in pairs(script.Parent:GetChildren()) do v.Touched:Connect(function(hit) print("e") if hit.Name == "Train" and hit:FindFirstChild("Moving") then print("a") local explos = Instance.new("Explosion") explos.Position = script.Parent.Position explos.Parent = script.Parent explos.BlastPressure = .4 hit.Parent.TrainHandler.Disabled = true hit.Chug:Stop() for i = 20,1,-1 do local End = hit.Parent:GetPrimaryPartCFrame()*CFrame.Angles(math.rad(90),0,0) local start = hit.Parent:GetPrimaryPartCFrame() hit.Parent:SetPrimaryPartCFrame(start:lerp(End,i)) end script.Parent.Explosion:Play() end end) end
He is using the touch event in a part not his train model. Well it is a descendant in the train model.
@TOP_Crundee123 You cant use Events in a loop, it dont have sense. and if a Player touch a Part that has a Model Parent, then the PART will activate the touched event, not the Model. Models dont have a touched event, you have right, but the Parts yes and if you touch a Model, you Touch the Part into the Model, not the Model self. You script cant work.
Actually, you can. If you use Collection Service, you would most likely put events in a loop, because what a loop does is to do something to whatever the loop iterated through
I know the Collection Service, but you cant make a event inside a loop. Outside the loop will work.
Try and you would find out that it works. I don’t want to sound rude, sorry.
Here’s an example. If you tag a button ui and you need it to have render stepped when the mouse button is down, not only are you putting a function inside a loop, but also another function
Uh, not really. The hit part is called Train and has Moving in it. Also, I just unanchored the other part and that seems to work.