Unable to cast value to Object with RemoteEvent

ewe

2 Likes

So… no code or anything? I’m not going to pull code out my ###, I’m not magic. We need this to troubleshoot. You didnt even show the full error.

3 Likes

sorry

Sever

script.Parent.ProximityPrompt.Triggered:Connect(function()
	for e,imagine in pairs(script.Parent:GetChildren()) do
		if imagine:IsA("Decal") then
			imagine:Destroy()
			game.ReplicatedStorage.RemoteEvent:FireClient()
		end
	end
end)

Client

game.ReplicatedStorage.Folder.random.OnServerEvent:Connect(function()
	
		local value = workspace.windo:GetChildren()
		local ReplicatedStorage = game.Workspace:WaitForChild("ShinyCuti")
		local random = value[math.random(1, #value)]
	    local ProximityPrompt = Instance.new("ProximityPrompt", random)
	    local Script = game.ReplicatedStorage.Script
	    Script:Clone().Parent = random
		ReplicatedStorage:Clone().Parent = random
end)
1 Like

you’re missing the player argument in
game.ReplicatedStorage.RemoteEvent:FireClient()
it doesn’t know which client to fire to.
change your server code to

script.Parent.ProximityPrompt.Triggered:Connect(function(plr)
	for e,imagine in pairs(script.Parent:GetChildren()) do
		if imagine:IsA("Decal") then
			imagine:Destroy()
			game.ReplicatedStorage.RemoteEvent:FireClient(plr)
		end
	end
end)

also, you’re using “OnServerEvent” in the client. It needs to be “OnClientEvent”

2 Likes

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