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

How do you stop errors on functions that are not called yet?

Asked by
wentman 19
6 years ago
Edited 6 years ago

Basically, I have a script with a function in it, and the function has a value that is nil until a RemoteFunction is called and overrides that value. Roblox returns an error on a line of code within that function because the mentioned value is nil before you even run that function and breaks it. Is there a way to stop Roblox from returning an error and breaking the script?

UPDATE Fixed it, thanks to this post

https://scriptinghelpers.org/questions/35839/fe-how-would-i-replicate-mousehitp-to-the-server

Code:

Server Script

local function Eqiop(player)

    if debounce then return end
if equip then
     MouseHit = ReplicatedStorage.Equip:InvokeClient(player)
--etc..
g1.CFrame = g1.CFrame:lerp(CFrame.new(Root.Position,MouseHit),.1)

LocalScript

function MouseInfo()
    return mouse.Hit.p
    end
        ReplicatedStorage.Equip.OnClientInvoke = MouseInfo()

Roblox Error

Workspace.wentman.Script:395: bad argument #2 to 'new' (Vector3 expected, got nil)

UPDATE== Removing line 395 returns another error,

     MouseHit = ReplicatedStorage.Equip:InvokeClient(player)

Trying to call method on object of type: Vector3 with incorrect arguments.

Answer this question