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)
01 | --Variables-- |
02 | local Players = game:GetService( "Players" ) |
03 | local button = script.Parent -- gets the button |
04 | print ( "VariablesDone!" ) --prints "VariablesDone!" |
05 | --MainScript-- |
06 | Players.PlayerAdded:Connect( function (plr) |
07 | print ( "playerJoined" ) |
08 | button.MouseButton 1 Click:Connect( function () --when a player presses the button in left click |
09 | script.Parent.Parent.Visible = false |
10 | print ( "Pressed" ) -- when a player presses the button then it will print out "Pressed" |
11 | end ) |
12 | end ) |
Remember, If you want to detect a user joining the script HAS to be in ServerScriptService
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
Put this in a LocalScript
.
1 | local Button = script.Parent -- Gets the button |
2 | Button.MouseButton 1 Click:Connect( function () -- When a player presses the button in left click |
3 | Button.Parent.Visible = false |
4 | print ( "Pressed" ) -- when a player presses the button then it will print out "Pressed" |
5 | end ) |