Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Player Joined script won't work in Filtering Enabled?

Asked by
iRexBot 147
7 years ago

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

Log in to vote
1
Answered by
INOOBE_YT 387 Moderation Voter
7 years ago

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.

0
It says 'OnClientEvent can only be used from client' iRexBot 147 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

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

0
It doesn't work iRexBot 147 — 7y
0
:Connect works just as fine as :connect. INOOBE_YT 387 — 7y
0
I still need an answer guys ;-; iRexBot 147 — 7y
0
@INOOBE_YT is right! thesit123 509 — 7y
Log in to vote
0
Answered by 7 years ago

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.

Log in to vote
0
Answered by
thesit123 509 Moderation Voter
7 years ago

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.

0
It no work rip. iRexBot 147 — 7y

Answer this question