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

I'm stuck, and will this work?

Asked by 9 years ago

So, I want this script to make the localplayer shoot a beam out of its head when the player presses Q. Script is:

tool = script.Parent
head = game.Workspace.Players.LocalPlayer:GetCharacterFromPlayer().WaitForChild("Head")
----------
tool.Equipped:connect(function(mouse)
mouse.KeDown:connect(function(key)
if key == "q" then
f =  Instance.new("Part")
f.Name = "Effect"
f.Shape = "Ball"
f.TopSurface = "Smooth"
f.BottomSurface = "Smooth"
f.Size = Vector3.new(3,3,3)
f.CFrame = head.CFrame
-- Stuck
end
end)
end)

-- Made by dragonmaster4111

1 answer

Log in to vote
-1
Answered by
jakedies 315 Trusted Moderation Voter Administrator Community Moderator
9 years ago

No, it wouldn't work. You would have to wait until the character exists and index the character directly, since that isn't a real method (though do not fear, there is a property of player that references the character called Character).

And it should be KeyDown and all you have to do after that is just parent it to workspace or whatever.

Edit: To reference the character from a player, all you have to do is:

--where player is defined as a player
local character = player.Character

And to shoot it up, just set the velocity to something like: Vector3.new(0, 100, 0)

0
Which line? And should I use lookvector? Operation_Meme 890 — 9y
0
No, just set it after you cframe'd it. jakedies 315 — 9y
Ad

Answer this question