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

Player Joined script won't work in Filtering Enabled?

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)

4 answers

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.

1 comment

0

It says 'OnClientEvent can only be used from client'

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

4 comments

0

It doesn't work

0

:Connect works just as fine as :connect.

0

I still need an answer guys ;-;

0

@INOOBE_YT is right!

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.

1 comment

0

It no work rip.

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