I am currently making a horror game and i'm trying to make a jumpscare of a person quickly running across the road. Someone helped me earlier but I can't get it to work.
I have this script in my ServerScriptStorage
local trigger = workspace:FindFirstChild("JumpTrigger"); 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}); --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);
I have my model named "Spooky" set up in the right spot aswell as 2 parts named "Start" and "Stop" on both sides of the road with the trigger being a transparent noncollideable block stretching across the road named "JumpTrigger".
I have been messing around and I still can't get it to work so maybe someone can help me fix it.
Sorry, I thought I did it but just looked. I created the Tween, but we aren't playing it
local trigger = workspace:FindFirstChild("JumpTrigger"); 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);
Updated code to Play() the tween as I forgot before.