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

Unable to cast value to Object?

Asked by 6 years ago

Okay i've been having this really annoying issue, what i'm trying to do is make a space station with an airlock, when you touch the outer airlock hitbox the server script sends a FireClient event that the player receives, then the client receives it and activates a fly local script, i'm having some issues with the server script, any help?

Error: https://gyazo.com/ce8ed13bfffcc39432abe61429921f3d

Script: https://gyazo.com/dbe6e3b87ed8ec6b276aeee8a0bec802

0
Please show code on this site so we do not have to go to another site to see it. hiimgoodpack 2009 — 6y
0
wew your code is messy im not gonna help u hiimgoodpack 2009 — 6y
0
how is my code messy you bloody carrot Ashley_Phantom 372 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

When you FireClient, the first argument must be the player you want to fire the event for. You've currently given it player1.Name, which is a string (which is why it is Unable to cast value to Object -- it can't turn a string into a player!). You probably want to do :FireClient(player1, player1.Name) (skip the local player2 = player1.Name as that variable name is misleading). Don't forget to make sure that player1 exists after assigning to it: if not player1 then return end (ie only fire the :FireClient line if player1 is not nil).

Ad

Answer this question