Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

FE RemoteEvent playerjoined script not working?

The script is suppost to give the user when they join a nametag and if they respawn it gives them one too. It doesn't work I tried my best to solve it but it doesn't work. Can anyone solve it and fix it and give it to me thanks in advanced :D

Script:


local storage = game:GetService('ReplicatedStorage')
local event = storage:WaitForChild('PlayerEvent')
local playerse = game:GetService('Players')

local function onAdded(plr)
	event:FireServer()
end

playerse.PlayerAdded:Connect(onAdded)

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		event:FireServer()
	end)
end)

Local script:



local Storage = game:GetService('ReplicatedStorage')
local Event = Storage:WaitForChild('PlayerEvent')
local Light = game:GetService('Lighting')
local Tag = Light:WaitForChild('Name')
function onFired(plr)
	local character = plr.Character
	if not character or not character.Parent then
		character = plr.CharacterAdded:wait()
		local name = Tag:Clone()
		name.Parent = character.Head
		if game:GetService("MarketplaceService"):PlayerOwnsAsset(plr, 664864882) then
			
		end
	end
end
Event.OnServerEvent:Connect(onFired)

1 answer

You are trying to fire the RemoteEvent's server-side from a server and trying to hook into it from a client. Simply, to fix this, you must change :FireServer() to :FireClient(player), and change .OnServerEvent:Connect to .OnClientEvent:connect. This should fix your issue.

Additionally, I'd remove the onAdded function in the Script as well as the line that says playerse.PlayerAdded:Connect(onAdded). Instead, I'd put event:FireClient(player) immediately after game.Players.PlayerAdded:connect(function(player), originally on line 11.

If you have trouble understanding this, please let me know. I'd be glad to help you further.

2 comments

0

Can you give me the fixed script version? I am still having some truoble

0

Also when I tried it says "OnClientEvent can only be used on the client" it comes from the main script not the local

This discussion is preserved as it was. New answers, comments, and votes are closed.