hello... im quite a good scripter but i never know how to do the thing of local the player i want to make tool that when clicked it puts a shot sound and put a bullet front of your torso and it moves front like a shot but i have the problem that the bullet needs to move to the "player" torso.. heres the script
function onActivation() shot:Play() local player = workspace.character local obj=script:FindFirstChildOfClass("Gun"):clone() obj.Parent=workspace obj:SetPrimaryPartCFrame(Player.Character.HumanoidRootPart.CFrame*CFrame.new(0,0,-3)) end
and im getting the error: character its not a valid member of workspace player
For someone who’s quite a good scripter, you sure do need to learn about errors!
All jokes aside, it’s just what the error says, character
is not a valid member of workspace
. If you are trying to make this in a local script, getting the player is as easy as game.Players.LocalPlayer, and if it’s not a local script, you can simply use the tool’s parent (which will ALWAYS be the player’s character if the tool is being held) to get your player’s character, and then the GetPlayerFromCharacter() method.
Another issue I noticed in your code! “Gun” is not a ClassType. As nice as it’d be to be able to simply Instance.new(“Gun”)
and have a perfectly working gun system, that’s not how it works. I think you’re looking for :FindFirstChild(“Gun”)
, which finds the first child with the name of gun as opposed to the class.
So do these steps!
Hope I could help!