Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Where do I need to put the closing parenthesis?

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

✓ Accepted answer

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.

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)

1 comment

0

Thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.