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

"Players.Backpack.Rasengan.Script:6: attempt to call a nil value" in server script?

I have a server script inside a tool and every time it gives me an error that says "Players.Backpack.Rasengan.Script:6: attempt to call a nil value" how do I fix this. Here is the script I am using:

local player = game.Players:GetPlayers()
local handle = script.Parent.Handle
local debounce = false
local Damage = 50
local tool = player.Backpack.Rasengan

handle.Touched:Connect(function(hit)
		if not debounce and hit.Parent.Humanoid then
			
		debounce = true
		
		local HitChat = game:GetService("Chat"):Chat(player.Character.Head, "RASENAGN!", "Red")
		
		local sound = Instance.new("Sound", game.Workspace)
		sound.SoundId = "rbxassetid://3245334797"
        sound:Play()
		print("play", sound.Playing, sound.TimePosition)

		local X = Instance.new("Part", workspace)
		X.Name = "Explosion"
		X.Shape = "Ball"
		X.Anchored = true
		X.CanCollide = false
		X.Size = Vector3.new(1.5,1.5,1.5)
		X.CFrame = player.Character.RightHand.CFrame
		X.BrickColor = BrickColor.new("Medium blue")
		X.TopSurface = "Smooth"
		X.BottomSurface = "Smooth"
		X.Material = "Neon"
		local C = Instance.new("BodyVelocity",hit.Parent.HumanoidRootPart)
		C.MaxForce = Vector3.new(math.huge,math.huge, math.huge)
		C.Velocity = player.Character.HumanoidRootPart.CFrame.lookVector * 50
		hit.Parent.Humanoid.Sit = true
		game.Debris:AddItem(C, 1.2)
		hit.Parent.Humanoid.Sit = false
		
		hit.Parent.Humanoid:TakeDamage(Damage)
		
		player.Character.Humanoid:UnequipTools(tool);
		
		for i = 1, 30 do
			X.Size = X.Size +Vector3.new(1,1,1)
			hit.Parent.UpperTorso.CFrame = hit.Parent.UpperTorso.CFrame * CFrame.fromEulerAnglesXYZ(0,0,1)
			X.CFrame = X.CFrame * CFrame.fromEulerAnglesXYZ(0,1,0)
			wait(0.05)
		end
		
		X:Destroy()
		sound:Stop()
		print("Sound has been destroyed")
		player.Character.Humanoid.WalkSpeed = 16
		print("Wait 10 seconds to Activate again")
		wait(3)
		debounce = false
		end
	end)

1 answer

✓ Accepted answer

The reason it may, not work was because it wasn't cloned in the backpack. Try this...

local player = game.Players:GetPlayers()
local handle = script.Parent.Handle
local debounce = false
local Damage = 50
local clonetool = game.ServerStorage.Rasengan:Clone()
clonetool.Parent = game.Players[Player.Name].Backpack

handle.Touched:Connect(function(hit)
        if not debounce and hit.Parent.Humanoid then

        debounce = true

        local HitChat = game:GetService("Chat"):Chat(player.Character.Head, "RASENAGN!", "Red")

        local sound = Instance.new("Sound", game.Workspace)
        sound.SoundId = "rbxassetid://3245334797"
        sound:Play()
        print("play", sound.Playing, sound.TimePosition)

        local X = Instance.new("Part", workspace)
        X.Name = "Explosion"
        X.Shape = "Ball"
        X.Anchored = true
        X.CanCollide = false
        X.Size = Vector3.new(1.5,1.5,1.5)
        X.CFrame = player.Character.RightHand.CFrame
        X.BrickColor = BrickColor.new("Medium blue")
        X.TopSurface = "Smooth"
        X.BottomSurface = "Smooth"
        X.Material = "Neon"
        local C = Instance.new("BodyVelocity",hit.Parent.HumanoidRootPart)
        C.MaxForce = Vector3.new(math.huge,math.huge, math.huge)
        C.Velocity = player.Character.HumanoidRootPart.CFrame.lookVector * 50
        hit.Parent.Humanoid.Sit = true
        game.Debris:AddItem(C, 1.2)
        hit.Parent.Humanoid.Sit = false

        hit.Parent.Humanoid:TakeDamage(Damage)

        player.Character.Humanoid:UnequipTools(tool);

        for i = 1, 30 do
            X.Size = X.Size +Vector3.new(1,1,1)
            hit.Parent.UpperTorso.CFrame = hit.Parent.UpperTorso.CFrame * CFrame.fromEulerAnglesXYZ(0,0,1)
            X.CFrame = X.CFrame * CFrame.fromEulerAnglesXYZ(0,1,0)
            wait(0.05)
        end

        X:Destroy()
        sound:Stop()
        print("Sound has been destroyed")
        player.Character.Humanoid.WalkSpeed = 16
        print("Wait 10 seconds to Activate again")
        wait(3)
        debounce = false
        end
    end)

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