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

PlayerAdded Not working How Do I Fix This?This Should Detect players When They Join

Asked by 4 years ago

Hey There!Im Sorry If Im getting Too Many Errors Lately But Im Just New So When The Script Gets 2 The Line Of script Containing My "PlayerAdded" Script The Whole script Stops Like When I play The Game And I Press The Button Nothing Works Tried Even printing After The PlayerAdded Here Is The Portion Of The Code: (keep In mind I Dont Have Any Variables Cointaning "Plr" So Yea)

--Variables--
    local Players = game:GetService("Players")
local button = script.Parent-- gets the button
    print("VariablesDone!")--prints "VariablesDone!"
    --MainScript--
    Players.PlayerAdded:Connect(function(plr)
    print("playerJoined")
    button.MouseButton1Click:Connect(function()--when a player presses the button in left click
        script.Parent.Parent.Visible = false
        print("Pressed")-- when a player presses the button then it will print out "Pressed"
    end)
end)
0
Also, localscripts ONLY work in gui's and backpack and alot of other stuff and run on client. 3F1VE 257 — 4y
0
This doesn't have to be on player added. This can be in a `LocalScript` that just connects the function. User#30567 0 — 4y

3 answers

Log in to vote
0
Answered by
3F1VE 257 Moderation Voter
4 years ago
Edited 4 years ago

Remember, If you want to detect a user joining the script HAS to be in ServerScriptService

1
This is actually not true. You can have it in workspace, but most people do it in serverscriptservice to keep it all neat, and go by the categories Roblox has made DarkDanny04 407 — 4y
0
true 3F1VE 257 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Maybe have a server script that checks when a player is added and it fires a remote event to the client telling it that a player joined

Log in to vote
0
Answered by 4 years ago

Put this in a LocalScript.

local Button = script.Parent -- Gets the button
Button.MouseButton1Click:Connect(function() -- When a player presses the button in left click
    Button.Parent.Visible = false
    print("Pressed") -- when a player presses the button then it will print out "Pressed"
end)

Answer this question