Need help with bug message

I simply got a code I don’t understand that’s all
@FroDev1002 already tried helping me with it, but I didn’t really understand the problem and I would like to understand it.

The error code says

Unable to cast value to Object

Can you share the script? Need more info than this

local replicated = game:GetService("ReplicatedStorage")
local function onTouch(hit)
	hit.CFrame = workspace.SpawnBox.SpawnLocation.CFrame + Vector3.new(0, 4, 0)
	replicated.Events.End:FireClient(true)
end
script.Parent.Touched:Connect(onTouch)

It says it’s on line 4

you need to specify which client to fire to inside :FireClient(), the first argument should be a player object

oh dang never knew that
dang is not a swear word right?

Are you trying to fire a specific client or all? If all you can use :FireAllClients()! It dosen’t require a player object and fires every client

Well, it is a 1P game (max 1 player per server) so yeah, it’s specific but actually all of them lol

1 Like

Oh, that removed the error code, but the game still doesn’t work. Mind taking a look?
FlappyBird.rbxl (85.3 KB)

(I’m aware my event system is nuts)

That is because FireClient requires the first argument to be a player, you need to ensure that the first argument is a player instance else it will error out or not work at all.

Seeing the logic of your code, you can get the player by doing:


local ReplicatedStorage= game:GetService("ReplicatedStorage")
local Events = ReplicatedStorage.Events
local Part = script.Parent
local SpawnBox = workspace.SpawnBox

local function onTouch(Hit)
	local Humanoid = Hit.Parent:FindFirstChildOfClass("Humanoid") or Hit.Parent.Parent:FindFirstChildOfClass("Humanoid")
	local Character = humanoid.Parent
	local Player = game.Players:GetPlayerFromCharacter(Character)
	Events.End:FireClient(Player)

	Humanoid.RootPart.CFrame = SpawnBox.SpawnLocation.CFrame + Vector3.new(0, 4, 0)
end
Part.Touched:Connect(onTouch)
1 Like

That gives an error

15:06:22.423 Workspace.FakeDeath.Resetter:1: attempt to index nil with ‘Parent’ - Server - Resetter:1

Had accidentally added a line.

Still has a bug tho

16:59:03.906 Workspace.FakeDeath.Resetter:8: attempt to index nil with ‘Parent’ - Server - Resetter:8

I am sure you are able to solve this yourself right.?
I wrote the script on mobile so I really can’t edit stuff all the time.

The issue is because I wrote humanoid not Humanoid so just change that.

oh ok lol
And nah I think I can’t
Or maybe I can idk I’m still a noob

Well then you should try at least. You aren’t going nowhere if you depend on people like me to help you in everything. It is just unethical and idiotic.

Good luck learning.

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