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

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

Asked by 10 years ago

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!

0
I've never heard of script.disabled... GetSporked 5 — 10y
0
Two copies of what? GoldenPhysics 474 — 10y
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 Perci1 4988 — 10y
0
i didnt see yours perci im sorry!! Chaserox 62 — 10y

1 answer

Log in to vote
1
Answered by 10 years ago

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)
Ad

Answer this question