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

Player Click with no Tool help?

Asked by 11 years ago

I want it where when a player clicks without a tool would shoot out a ball from the torso. And it is in a LocalScript in StarterPack

1game.Players.LocalPlayer.MouseButton1Click:connect(function()
2    Brick = Instance.new("Part")
3    Brick.Shape = "Ball"
4    Brick.Size = Vector3.new(3,3,3)
5    Brick.BrickColor = BrickColor.Random(3, 5, 9, 1)
6end)

Thank you.

1 answer

Log in to vote
3
Answered by 11 years ago

If you're using a LocalScript you can do this to detect when a player has pressed the left mouse button down:

01local player=Game.Players.LocalPlayer
02local mouse=player:GetMouse()
03 
04mouse.Button1Down:connect(function()
05    Brick = Instance.new("Part",Workspace)
06    Brick.Position=player.Character:WaitForChild("Torso").Position
07    Brick.Shape = "Ball"
08    Brick.Size = Vector3.new(3,3,3)
09    Brick.BrickColor = BrickColor.Random(3, 5, 9, 1)
10end)
0
What about the brick.new thing, do I just plop that in there? Grenaderade 525 — 11y
0
Sure. TheGuyWithAShortName 673 — 11y
0
Okay, I just did it, but it does not work. Grenaderade 525 — 11y
0
The brick does not spawn. Grenaderade 525 — 11y
View all comments (4 more)
0
You weren't parenting the brick at all, so you couldn't see it. I've updated my answer with the correct code. TheGuyWithAShortName 673 — 11y
0
It works! But how would I make it shoot out, like if it were a gun. Grenaderade 525 — 11y
0
You could use BodyMovers. If you don't know what those are, you can look them up on the Roblox Wiki. TheGuyWithAShortName 673 — 11y
0
How would I put a body mover in it? Grenaderade 525 — 11y
Ad

Answer this question