So the script is suppost to do when you join the game it fires and when you respawn it fires too. But it keeps saying "clients cannot be fired from server" I am confused with this. Can anyone possibly give me a fix for this script?
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)
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)
I think you need to change the scripts around, the script have:
event:FireClient()
and the local script should have:
Event.OnClientEvent:Connect(onFired)
I think this could help.
Okay one thing I can see wrong is:
playerse.PlayerAdded:Connect(onAdded)
it should be
players.PlayerAdded:connect(onAdded)
Also in the first local script, you used a capital C for connect.
I'm not sure if there is anything else but that's what I spotted
You are using :FireServer()
in the Script which should be used in the LocalScript. You are using OnServerEvent
in the LocalScript which should be used in the Script.
There are few necessary lines, in my opinion.
LocalScript
local storage = game:GetService('ReplicatedStorage') local event = storage:WaitForChild('PlayerEvent') local playerse = game:GetService('Players') game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) event:FireServer() end) end)
Normal 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.CharacterAdded:wait() local name = Tag:Clone() name.Parent = character.Head game:GetService("MarketplaceService"):PlayerOwnsAsset(plr, 664864882) end end Event.OnServerEvent:Connect(onFired)
I don't even know if I'm right or not, Sigh.