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

How do i make a script go into a player on startup?

FIRST SCRIPT THAT GIVES THE PLAYER THE SCRIPT

function Joined(Player)
	plr = game.Workspace:WaitForChild(Player.Name)
	wait(3)
	a = script.Script:clone()
	a.Parent = plr
	a.Disabled = false
end
game.Players.PlayerAdded:connect(Joined)

SECOND SCRIPT CHECKS IF VALUE IS TRUE IF IT ISNT THEN PUTS A STRINGVALUE INTO THE PLAYER

NOTE THERE IS A PROBLEM THAT TWO COPIES ARE GOING INTO ONE PLAYER AND THE SECOND PLAYER GETS NONE!

while true do
		wait()
	if game.Workspace.Room1.Value == false then
		game.Workspace.Room1.Value = true
	ro = Instance.new("StringValue")
	ro.Value = "RoomA"
	ro.Name = "Room"
	ro.Parent = game.Players.LocalPlayer.Character	
	wait(5)
script.Disabled = true
script:Destroy()


end
	
	 if game.Workspace.Room2.Value == false then
	game.Workspace.Room2.Value = true
	ro = Instance.new("StringValue")
	ro.Value = "RoomB"
	ro.Name = "Room"
	ro.Parent = game.Players.LocalPlayer.Character
	script.Parent.Script:Destroy()
	wait(1)
	end
	end



Please help it will mean alot!! You will be mentioned in my game if you help me!

4 comments

0

I've never heard of script.disabled...

0

Two copies of what?

1

I leave you a detailed answer and all you change is make it a local script that still won't work? https://scriptinghelpers.org/questions/9156/can-someone-help-me-fix-this

0

i didnt see yours perci im sorry!!

1 answer

This is the best I can interpret your problem. I used the Character property of Player instead of searching through workspace. I also used an anonymous function to shorten the code slightly. It will also check for the Character every half second and proceed only when it's found.

game.Players.PlayerAdded:connect(function(plr)
	repeat wait(.5) until plr.Character
	a = script.Script:clone()
	a.Parent = plr.Character
	a.Disabled = false
end)

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