I got the script to do what I wanted at first then tried to use math.random. Now when I try to run it, is says something like " ')' expected to close" and whenever I try to place is somewhere it has a red line.~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~
local player = game.Players.LocalPlayer
local tramp = game.Workspace["tramp"]
while true do
tramp.Touched:Connect(function(Hit)
if Hit then
wait(1)
trick = math.random(1,2)
if trick == 1 then
local animation = Instance.new("Animation")
animation.AnimationId="rbxassetid://1891421869"
local ActPlay = player.Character.Humanoid:LoadAnimation(animation)
ActPlay:Play()
elseif
trick == 2 then
local animation = Instance.new("Animation")
animation.AnimationId="rbxassetid://1977977345"
local ActPlay = player.Character.Humanoid:LoadAnimation(animation)
ActPlay:Play()
end
end
end
This appears to be what you're looking for?
local player = game.Players.LocalPlayer local tramp = game.Workspace["tramp"] while true do tramp.Touched:Connect(function(Hit) if Hit then wait(1) trick = math.random(1,2) if trick == 1 then local animation = Instance.new("Animation") animation.AnimationId="rbxassetid://1891421869" local ActPlay = player.Character.Humanoid:LoadAnimation(animation) ActPlay:Play() elseif trick == 2 then local animation = Instance.new("Animation") animation.AnimationId="rbxassetid://1977977345" local ActPlay = player.Character.Humanoid:LoadAnimation(animation) ActPlay:Play() end end end) -- required a closing ) here end -- required another end here
You required a closing )
from opening it on your Connect
line.
However, it's probably worth nothing that you don't need the while
loop here, and having it will probably destroy your game.
endtramp.Touched
-> tramp.Touched
from ROBLOX Studio being stupid.
You use the ) in anonymous functions. So:
pcall(function() end) Event:Connect(function() end) spawn(function() end) delay(4, function() end)
Anything like that is an anonymous function, and require an end)