I was finishing up my local script, and I'd thought all of the bugs were squashed, accept that the Water - or wavelike block - wasn't showing up by my hand moving forward, rather in the workspace, in a spot right by the spawn. I've been at this for about thirty minutes, but on the last attempt, I got -
Players.fighterkirbyzx.Backpack.WaterShot.LocalScript:13: attempt to index a nil value
Here's the code-
local Water = game.ReplicatedStorage.Water local Shooter = script.Parent local Waterclone = Water:Clone() local Canshoot = true local person = game.Players.LocalPlayer local mouse = person:GetMouse() local function onclick() Canshoot = false Waterclone.Parent = game.Workspace Waterclone.CFrame = CFrame.new(person:FindFirstChildWhichIsA("RightHand").Position) Waterclone.Velocity = Vector3.new(0, 0, 0) wait(.8) Waterclone:Destroy() Canshoot = true end mouse.Button1Down:Connect(onclick)
Anyone know why?
Easy
In your script person
is player not character. Just change it to person.Character
and use FindFirstChild()
local Water = game.ReplicatedStorage.Water local Shooter = script.Parent local Waterclone = Water:Clone() local Canshoot = true local person = game.Players.LocalPlayer local mouse = person:GetMouse() local function onclick() Canshoot = false Waterclone.Parent = game.Workspace Waterclone.CFrame = CFrame.new(person.Character:FindFirstChild("RightHand").Position) Waterclone.Velocity = Vector3.new(0, 0, 0) wait(.8) Waterclone:Destroy() Canshoot = true end mouse.Button1Down:Connect(onclick)
This is why you need to check your script.