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

I have a script that blows people back but doesn't work any ideas?

Asked by
AM910sk 22
5 years ago
Edited 5 years ago

So in my script, It says that the character that is hit by it gets blown back and I have a variable called player that defines game.players.localplayer but it says that player is a nil value in the output. 19:43:56.331 - Players.AM910SK.Backpack.Rasengan.Script:11: attempt to index upvalue 'player' (a nil value)

Script:

01local player = game.Players.LocalPlayer -- this is the variable player
02local handle = script.Parent.Handle
03local debounce = false
04 
05handle.Touched:Connect(function(hit)
06    if not debounce and hit.Parent.Humanoid then
07        debounce = true
08        hit.Parent.Humanoid:TakeDamage(50)
09        local blowback = Instance.new("BodyVelocity")
10        blowback.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
11        blowback.Velocity = player.Character.HumanoidRootPart.CFrame.lookVelocity*50 --it says that player is a nil value right here
12        hit.Parent.Humanoid.Sit = true
13        game.Debris:AddItem(blowback, 1.2)
14        wait(3)
15        debounce = false
16    end
17end)

Answer this question