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

Player Click with no Tool help?

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

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

Thank you.

1 answer

✓ Accepted answer

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

local player=Game.Players.LocalPlayer
local mouse=player:GetMouse()

mouse.Button1Down:connect(function()
    Brick = Instance.new("Part",Workspace)
    Brick.Position=player.Character:WaitForChild("Torso").Position
    Brick.Shape = "Ball"
    Brick.Size = Vector3.new(3,3,3)
    Brick.BrickColor = BrickColor.Random(3, 5, 9, 1)
end)

8 comments

0

What about the brick.new thing, do I just plop that in there?

0

Sure.

0

Okay, I just did it, but it does not work.

0

The brick does not spawn.

0

You weren't parenting the brick at all, so you couldn't see it. I've updated my answer with the correct code.

0

It works! But how would I make it shoot out, like if it were a gun.

0

You could use BodyMovers. If you don't know what those are, you can look them up on the Roblox Wiki.

0

How would I put a body mover in it?

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