Hi.
I have a weird phone that you can use to dial weird numbers and affect the environment (don't judge me).
But the problem I'm encountering is when it's dialed, it's supposed to make a message in the chat: "Player has dialed number 1800LOLFAKE -- and it was valid! Something happened!" or "Player has dialed number 1800LOLSTOP, but it wasn't valid, so nothing happened.", depending on whether the number is valid or not.
It doesn't do that, though. Instead, it returns an error:
Unable to cast value to Object Stack Begin Script 'Workspace.Phone.Dial.Script', Line 14 Stack End
Here's the script that doesn't work:
-- Get Events
local event = game:GetService("ServerStorage").Event
local dial = game:GetService("ReplicatedStorage").DialNotify
-- Get Input
local input = script.Parent.Parent.Input
-- Get ClickDetector
local click = script.Parent.ClickDetector
-- Make validity
local valid;
click.MouseClick:connect(function(p) -- c l i c k c l i c k
if input.Value == "666" then
valid = true
event:Fire("Spook"); dial:FireClient(p.Name, input.Value, valid)
elseif input.Value == "777" then
valid = true
event:Fire("Happy"); dial:FireClient(p.Name, input.Value, valid)
else
valid = false
dial:FireClient(p.Name, input.Value, valid)
end
input.Value = "" -- Delete input
end)
Why is this happening, and how can I fix it?
kthxbye

1 comment
FireClient requires the player object not the player name which is a string. Just use p since this holds the player object.