Velocity doesn't work in LocalScripts?

Hi,
I’ve recently turned a script in my game from a regular script to a local script because some features were just better to do on the client side. What I noticed was that the velocity I set in the script wasn’t working in the local script. While the regular script would make the object I wanted to work on fling away, the local script did not do anything and the object stayed in the same place.

Heres the script:

local position = game.Workspace.KingBunny.Position

local myX = position.x

local myY = position.y

local myZ = position.z

local function onPartTouched(otherPart)

	game.Workspace.KingBunny.Velocity = Vector3.new(myX, myY+300, myZ+100)

end

1 Like

showing the script would be useful.

1 Like

My friend just tried the same game I’m working on and said it worked for him and we are on the same version. I’ll try restarting my computer and tell you how it goes.

Nope still doesn’t work for me, i’ll just try it on regular Roblox instead of play testing.

Did you connect your function to a touched event?

yes im just not showing it in the example right now I just think it might be issues specific to me.

If you’re doing this from a LocalScript, I believe you need to make sure that the LocalScript that is calling this physically owns the KingBunny part. This can be done server-side with the SetNetworkOwner method.

2 Likes

My second best bet is you’ll need to fire an event and when the event i received in a local script, do those things. I do think that there is a better solution.

Edit: Yup, there is thanks to @sleitnick

1 Like

You cannot modify the physics based properties of a part and expect it to replicate/work if you do not have ownership of the part in reference. You have to read up on NetworkOwnership and set it up to the player wanting to apply the velocity before actually applying it. This only applies for local scripts.

Network owner of a part can only be set on the server.

-- Player to change ownership to
local Player

workspace.KingBunny:SetNetworkOwner(Player)

Where is the script located? it may help us

sorry I forgot to mark the solution.