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

I'm stuck, and will this work?

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

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)

2 comments

0

Which line? And should I use lookvector?

0

No, just set it after you cframe'd it.

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