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

do body velocities not work locally?

Asked by
Kaput_0 44
4 years ago
Edited 4 years ago

and I'm back again trying to work on my 2d character mover, again avoiding the use of a humanoid because that was made for 3d and really doesn't allow me access to edit individual movement settings, so I'm using body movers or body forces or whatever they all honestly sound the same to me, I'm simply trying to make my character move left and right (starting with right) and moving a pill-shaped colidor (separate from the avatar) balanced with a bodygyro and a camera following it every RunService heartbeat, all in a local script inside starterplayerscripts

properties are changing in the explorer and everything but the colidor object is not moving at all, I even tested the amount of force running the game and editing the property myself and that made the thing fly off as I expected but using the local script (and remote events) it just never worked, I need to know what exactly is going wrong and if there are any hidden properties (which somehow exist in body movers for some reason?)

edit: just made the colidor massless, did absolutely nothing lol

--This script uses Intended_Pun's Useful Functions. Wiki: https://github.com/Klink45/UsefulFunctions/wiki 
local uf = require(game.ReplicatedStorage.UsefulFunctions.Module)

local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")

local Cam = workspace.CurrentCamera
local PlRoot = workspace.Player.PlrColS
local MForce = workspace.Player.PlrColS.BodyVelocity

local Movementforce = 10000

--[[RunService.Heartbeat:Connect(function()
    Cam.CFrame = PlRoot.CFrame + Vector3.new(-25,0,0)
    Cam.CFrame = Cam.CFrame * CFrame.Angles(math.rad(-90),0,math.rad(90))
end)]]--

UserInputService.InputBegan:Connect(function(Input,Prosessed)
    if not Prosessed then
        if Input.KeyCode == Enum.KeyCode.D then
            MForce.Velocity = Vector3.new(0,0,Movementforce)
        end
    end
end)

UserInputService.InputEnded:Connect(function(Input,Prosessed)
    if not Prosessed then
        if Input.KeyCode == Enum.KeyCode.D then
            MForce.Velocity = Vector3.new(0,0,0)
        end
    end
end)

Cam.CameraType = Enum.CameraType.Scriptable
Cam.CFrame = workspace.STcam.CFrame
Cam.CameraSubject = workspace.Player.PlrColS 

1 answer

Log in to vote
0
Answered by
Y_VRN 246 Moderation Voter
4 years ago

If you're using a LocalScript to do this, it won't work because of both workspace.FilteringEnabled and (I might be wrong about this...) NetworkOwnership of parts being set to the server (physics calculations are done most of the time in the server. we're not gonna talk about this it is somewhat complicated but i'll provide a link if you're still interested.)

You need to be using server Scripts for this. If you still want to do this "locally," you'll have to learn about RemoteEvents and RemoteFunctions, (and optionally NetworkOwnership).

Links:

RemoteEvents and Functions *(useful for server-client communication when FE is enabled): https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events

workspace.FilteringEnabled: https://developer.roblox.com/en-us/api-reference/property/Workspace/FilteringEnabled

Network Ownership (again I might be wrong about this. this is optional): https://developer.roblox.com/en-us/articles/Network-Ownership

Ad

Answer this question