Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How can I make a move trigger?

Asked by 4 years ago

How would I make a trigger that moves an object? I am making a horror game and I want it so once the player reaches a certain point a shadow moves across the road in front of them.

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Easy way to do this is with a .Touched event on a part.

Script in ServerScriptService

local trigger = workspace:FindFirstChild("TriggerBlock");
local spooky = workspace:FindFirstChild("Spooky");
local start, stop = workspace:FindFirstChild("Start"), workspace:FindFirstChild("Stop");


trigger.Touched:Connect(function(hit)
  if hit.Parent:FindFirstChild("Humanoid") then
    spooky.CFrame = start.CFrame;
    game:GetService("TweenService"):Create(spooky, TweenInfo.new(1), {CFrame = stop.CFrame}):Play(); --The one represents one second, or how long it will take "spooky" to run across the hall, CFrame = stop.CFrame will make spooky run from start.CFrame to stop.CFrame in 1 second.
  end;
end);

If this helped, please mark it as the solution so people know your question has been answered, and if you have other questions feel free to ask.

0
So, i'd name the object I want to move "Spooky" or replace "Spooky with the objects name? onehappypie 5 — 4y
0
Okay, I have my jumpscare placed and named "Spooky", I have 2 parts named "Stop" and "Start" and have placed them in position of where i'd like the jumpscare to head. I have placed a transparent and non-collideable "TriggerBlock" and have set it up but Spooky won't move. onehappypie 5 — 4y
0
All 4 parts are just children of workspace correct? MrLonely1221 701 — 4y
Ad

Answer this question