ThatsRafa
(Douma)
September 4, 2022, 12:58pm
#1
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!
Before the error occurred (saved game file): https://gyazo.com/46caf73c03f87bda476e607066cde996
After the error occurred (main game file): https://gyazo.com/23087c15da48b69bc8c90b445a1d361f
3 Likes
syntaqs
(syntax)
September 4, 2022, 1:35pm
#2
Can you send us the script please? It’s nearly impossible to help you if we can’t know what’s wrong.
2 Likes
ThatsRafa
(Douma)
September 4, 2022, 1:40pm
#3
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
syntaqs
(syntax)
September 4, 2022, 1:42pm
#4
What’s the error you’re receiving in the output?
I think this is the cause of your problem.
1 Like
ThatsRafa
(Douma)
September 4, 2022, 1:43pm
#5
I don’t receive any sadly. -------
ThatsRafa
(Douma)
September 4, 2022, 1:43pm
#6
Well, I already replaced it by using math.huge
syntaqs
(syntax)
September 4, 2022, 1:44pm
#7
I didn’t realize you’ve just edited the message.
1 Like
ThatsRafa
(Douma)
September 4, 2022, 1:44pm
#8
Oh ok. Tell me if you see anything wrong please
syntaqs
(syntax)
September 4, 2022, 1:45pm
#9
Can you show me the full script?
1 Like
ThatsRafa
(Douma)
September 4, 2022, 1:47pm
#10
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)
iSophes
(Sophie)
September 4, 2022, 1:50pm
#11
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
syntaqs
(syntax)
September 4, 2022, 1:50pm
#12
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
elomala
(elomala)
September 4, 2022, 1:51pm
#13
Maybe try parenting the Knockback to the attachment
Knockback.Parent = Attachment
1 Like
ThatsRafa
(Douma)
September 4, 2022, 1:54pm
#14
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.
iSophes
(Sophie)
September 4, 2022, 1:56pm
#15
Is this code the exact same in the test place and the current one?
1 Like
ThatsRafa
(Douma)
September 4, 2022, 1:57pm
#16
Yes, they are both the exact same scripts.
ThatsRafa
(Douma)
September 4, 2022, 1:59pm
#17
That didn’t work sadly. (limit)
ThatsRafa
(Douma)
September 4, 2022, 2:16pm
#19
Does anyone know why this happens?
ThatsRafa
(Douma)
September 4, 2022, 3:11pm
#20
I’ve just discovered that even in the saved game file, after a while it will stop working and not knockback
ThatsRafa
(Douma)
September 5, 2022, 2:05am
#21
Can someone please help me? This is urgent!