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

Why won't my dummy move with LinearVelocity?

Asked by 2 years ago

So, I am trying to create a combat system, and I am currently experimenting with some things. I want to make a script that basically knocks up the nearest player (did not implement that yet, i am still experimenting) and i already ran into some issues.

01local dummy = game.Workspace.Dummy
02local dHum = dummy:FindFirstChild("Humanoid")
03local dHRP = dummy:FindFirstChild("HumanoidRootPart")
04 
05local UIS = game:GetService("UserInputService")
06local deb = false
07 
08UIS.InputBegan:Connect(function(input, gpe)   
09    if gpe then return end
10 
11    if input.KeyCode == Enum.KeyCode.Q and not deb then
12        deb = true
13 
14        dHum.WalkSpeed = 0
15        dHum.JumpPower = 0
View all 27 lines...

basically I add a linearvelocity to the dummy's HumanoidRootPart, and so i thought to myself "This should move the dummy upwards, right?"

Welp, i was not right, please help

1 answer

Log in to vote
1
Answered by 2 years ago
Edited 2 years ago

You forgot to set Attachment0.

Also when setting an NPC's velocity, always do it in a server script. To achieve that, you must use a RemoteEvent. It must be parented to ReplicatedStorage and named DummyVelocity.

LocalScript in StarterPlayerScripts or StarterGui:

01local RS = game:GetService("ReplicatedStorage")
02local RE = RS:WaitForChild("DummyVelocity")
03local UIS = game:GetService("UserInputService")
04 
05UIS.InputBegan:Connect(function(input, gpe)   
06    if gpe then return end
07    if input.KeyCode == Enum.KeyCode.Q then
08        RE:FireServer()
09    end
10end)

Script inside the dummy's HumanoidRootPart.

01local dHRP = script.Parent
02local dummy = dHRP.Parent
03local dHum = dummy:FindFirstChildOfClass("Humanoid")
04 
05local RS = game:GetService("ReplicatedStorage")
06local RE = RS.DummyVelocity
07local Debris = game:GetService("Debris")
08local deb = false
09 
10RE.OnServerEvent:Connect(function()
11    if not deb then
12        deb = true
13 
14        dHum.WalkSpeed = 0
15        dHum.JumpPower = 0
View all 31 lines...
0
it still did not work for some reason lolmarios2647 46 — 2y
0
Wdym I even tested it in studio myself. T3_MasterGamer 2189 — 2y
0
same bro, did not work. Where did you put the LocalScript? lolmarios2647 46 — 2y
0
I edited the answer. Just follow the instructions and it should work. T3_MasterGamer 2189 — 2y
View all comments (2 more)
0
bro i am not even kidding you, it's still not working. I followed the instructions word to word and it'sstill not working. If you have discord i can show you there. lolmarios2647 46 — 2y
0
nevermind, it worked, for some reason i tested it twice, with the first time having no errors at all and it still did not work, but it worked now so thank you, i appreciate the help lolmarios2647 46 — 2y
Ad

Answer this question