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

Where do I need to put the closing parenthesis?

Asked by 5 years ago
Edited 5 years ago

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

2 answers

Log in to vote
0
Answered by
fredfishy 833 Moderation Voter
5 years ago
Edited 5 years ago

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.

edit

endtramp.Touched -> tramp.Touched from ROBLOX Studio being stupid.

Ad
Log in to vote
1
Answered by 5 years ago

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)

0
Thanks ReaperWolf101 7 — 5y

Answer this question