Unable to cast value to Object

LocalScript, inside ScreenGui

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local makeFade = ReplicatedStorage.Events:WaitForChild("makeFade")

local Frame = script.Parent.Frame
local Title = Frame.Title
local Location = Frame.Location

makeFade.OnClientEvent:Connect(function(name)
	Location.Text = tostring(name)
	Frame.Visible = true
	wait(3)
	Frame.Visible = false
end)

ServerScript, inside ProximityPrompt

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local makeFade = ReplicatedStorage.Events:WaitForChild("makeFade")
location = script.Parent.ObjectText

script.Parent.Triggered:Connect(function(player)
	makeFade:FireClient("Cave")
end)

Getting error

Unable to cast value to Object
Stack Begin - Studio
21:46:37.664 Script ‘Workspace.Proximity.Attachment.ProximityPrompt.Script’, Line 6 - Studio - Script:6
21:46:37.664 Stack End - Studio

Any help? Tried looking for other posts for this, just cant seem to find any that work

Try this,

makeFade.OnClientEvent:Connect(function(name: string)
	Location.Text = name
	Frame.Visible = true
	wait(3)
	Frame.Visible = false
end)
script.Parent.Triggered:Connect(function(player)
	makeFade:FireClient(player, "Cave")
end)
  • You Forgot to add the Player Variable into FireClient

  • name: string makes it so the Variable is a string and not any, (remove it if you like)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.