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 10 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

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

Log in to vote
3
Answered by 10 years ago

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)
0
What about the brick.new thing, do I just plop that in there? Grenaderade 525 — 10y
0
Sure. TheGuyWithAShortName 673 — 10y
0
Okay, I just did it, but it does not work. Grenaderade 525 — 10y
0
The brick does not spawn. Grenaderade 525 — 10y
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 — 10y
0
It works! But how would I make it shoot out, like if it were a gun. Grenaderade 525 — 10y
0
You could use BodyMovers. If you don't know what those are, you can look them up on the Roblox Wiki. TheGuyWithAShortName 673 — 10y
0
How would I put a body mover in it? Grenaderade 525 — 10y
Ad

Answer this question