Script is acting weird, help!

Hello, I have been trying to do a knockback script where you can push Dummies back, and it worked, until suddenly my script stopped working. I opened a save file, and it works as intended, even though it’s before that occurred and the script is literally the same as the actual one. And for some reason it doesn’t work in the main game file. Please help!

  1. Before the error occurred (saved game file): https://gyazo.com/46caf73c03f87bda476e607066cde996

  2. After the error occurred (main game file): https://gyazo.com/23087c15da48b69bc8c90b445a1d361f

3 Likes

Can you send us the script please? It’s nearly impossible to help you if we can’t know what’s wrong.

2 Likes

Sure, but I don’t really think it’s the script

	local Character = Player.Character or Player.CharacterAdded:Wait()
	local Magnitude = (PlayerWhoIsSlapped.HumanoidRootPart.Position - Character.HumanoidRootPart.Position).Magnitude

	if Magnitude <= 5 then
		PlayerWhoIsSlapped.Humanoid:TakeDamage(10)
		
		local Attachment = Instance.new("Attachment")
		Attachment.Name = "Attachment"
		Attachment.Parent = PlayerWhoIsSlapped.HumanoidRootPart
		
		local Knockback = Instance.new("LinearVelocity")
		Knockback.MaxForce = math.huge
		Knockback.VectorVelocity = PlayerWhoIsSlapped.HumanoidRootPart.CFrame.LookVector * 50
		Knockback.Attachment0 = Attachment
		Knockback.Name = "LinearVelocity"
		Knockback.Parent = PlayerWhoIsSlapped.HumanoidRootPart
		
		wait(1)
		Knockback:Destroy()
	end
end)

Also no errors are printed

What’s the error you’re receiving in the output?

I think this is the cause of your problem.

1 Like

I don’t receive any sadly. -------

Well, I already replaced it by using math.huge

I didn’t realize you’ve just edited the message.

1 Like

Oh ok. Tell me if you see anything wrong please

Can you show me the full script?

1 Like

The only thing in the server script I missed was:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local RemoteEvent = ReplicatedStorage:WaitForChild("Knockback")

RemoteEvent.OnServerEvent:Connect(function(Player, PlayerWhoIsSlapped)

Can you send us the local script you are using as well as it sems that you are receiving an event from there - maybe it could be in there.

Also maybe litter your code with prints. That helps at times.

1 Like

Is that script the source of your error? If not, try finding the script that is the source of your error and show it to us.

1 Like

Maybe try parenting the Knockback to the attachment

Knockback.Parent = Attachment
1 Like

I think it is, since that’s the only knockback script and we can see that the Dummy takes 50 damage and that’s right before the knockback script.

Is this code the exact same in the test place and the current one?

1 Like

Yes, they are both the exact same scripts.

That didn’t work sadly. (limit)

Does anyone know why this happens?

I’ve just discovered that even in the saved game file, after a while it will stop working and not knockback

Can someone please help me? This is urgent!