It doesn’t work
It does nothing
It doesn’t work
It does nothing
No errors right? Then let’s relook at what you’re trying to do here. Basically, you are detecting inputs from the user and use a RemoteEvent to add BodyVelocity to the target if it is a valid character with a Humanoid.
Alright, if you’re not testing it with someone, then it means you’re testing it with a NPC. Have you checked if the NPC is anchored? If the NPC is anchored, force such as BodyVelocity will not work on the NPC. (when i spawn npc from roblox studio, the humanoidrootpart is usually anchored, so check that)
I’m testing it with a player not npc
if i test it with a npc the BodyVelocity doesn’t work even if i unanchored the HumanoidRootPart
When any humanoid isnt sitting any velocidy aplied are nulified, you may want set Sit of humanoid to true before aplying velocity
how would i do that?
need more characters
character.Humanoid.Sit = true
Also I just noticed
First argument for OnServerEvent event is a player that triggered remote event and then arguments that you specified in localscript.
Change
remote.OnServerEvent:Connect(function(target , mouseCFrame)
to
remote.OnServerEvent:Connect(function(plr, target , mouseCFrame)
plr
is the player who fired the remote.
it will just break the code
.
What do you mean? Your code won’t work either way because otherwise it assigns the Player
argument to your target
parameter.
tried that already (doesn’t work)
I think it’s also because you’re passing over the following datatypes when firing the remote:
:FireServer(BasePart?, boolean, string)
When the server accepts
:Connect(function(BasePart?, CFrame)
Basically, you should instead fire the remote with
:FireServer(mouse.Target, mouse.Hit)
Still doesn’t work
.
--LOCAL
local replicated = game:GetService("ReplicatedStorage")
local remote = replicated:WaitForChild("Hitted1")
local players = game:GetService("Players")
local player = players.LocalPlayer
local mouse = player:GetMouse()
local tool = script.Parent
tool.Activated:Connect(function()
if mouse.Target then
remote:FireServer(mouse.Target, mouse.Hit)
end
end)
--SERVER
local replicated = game:GetService("ReplicatedStorage")
local remote = replicated.Hitted1
remote.OnServerEvent:Connect(function(player, mouseTarget, mouseHit)
local targetModel = mouseTarget:FindFirstAncestorOfClass("Model")
if targetModel then
local targetHuman = targetModel:FindFirstChildOfClass("Humanoid")
if targetHuman then
local targetRoot = targetModel:FindFirstChild("HumanoidRootPart")
if targetRoot then
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyVelocity.P = 1500
bodyVelocity.Velocity = (-targetRoot.CFrame.UpVector) * 100
bodyVelocity.Parent = targetRoot
task.wait(0.5)
bodyVelocity:Destroy()
end
end
end
end)
This is working for me (assuming you wanted to create a fling tool).
file.rbxm (4.4 KB)
it works but sometimes it pushes the player down the platform
(-targetRoot.CFrame.UpVector) * 100
Replace this bit with.
(targetRoot.CFrame.UpVector) * 100
I wasn’t sure if you wanted to fling down or up.
now the Player Just Floats And Not Pushing Forwards
task.wait(0.5)
There’s a 0.5 second gap, you may want to decrease/increase this to get the desired result.