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

"Rebooting" a localscript? [Solved] [closed]

Asked by
Jackd44 35
10 years ago

EDIT: In the end, I solved it by moving the localscript into starterpack, this has also made my script more efficient as I used to have a script in every surfaceGUI, now I have only one in each player that controls all the logic, incase anyone is interested(as this could possibly come in handy for some person in the future who also runs into this problem!), I'll post the finalised code.

function moved()
    print("Moved started")
    wait(0.1)
    local player = game.Players.LocalPlayer
    if player.Name ~= game.Workspace.currIt.Value then
    local lp = player.Character.Localparts:GetChildren()    
    for i = 1, #lp do   
    local puzz = lp[i].Part.Puzz
    puzz.Parent = player.PlayerGui
    puzz.Adornee = lp[i].Part
    print("Adornee set to "..lp[i].Part.Name)
    print("Puzz cloned into "..player.Name.."'s PlayerGui")
    local list = game.ReplicatedStorage.puzzles:GetChildren()
    local game = list[math.random(#list)]
    game:Clone().Parent = puzz
    print("Minigame cloned")
    end
    end
end 

game.Workspace.currMap.Changed:connect(moved)

Warning now, this is a fairly long post, and I will understand if you don't have the time to read it all, if you are in a rush and only need the basics of it, a line or two of the part above the code, the code itself and the part below it will be of help enough itself, the top 6 lines or so aren't that important. :)

Hello, I've recently been hard at work with a new game. And I've run into a hard problem, my problem is I need to insert local parts into everyone, I also have a surfaceGUI inside of them and I need to copy that surfaceGUI into every player's backpack. However, that's not really the point(I just thought I'd give a little background incase it's needed, I like to try and make my questions as easy to answer as possible). I think I've got that covered, but the main problem is this(this might not be worded all that well, sorry!), I have a model that is pasted into a message in each player's character(the code for this isn't that bad, it's not the problem) and inside the model are bricks, these are supposed to be local to stop a certain player from accessing them. Inside the bricks are surfaceGUI's and the following localscript:



function moved() print("Moved started") wait(0.1) local player = game.Players.LocalPlayer if player.Name ~= game.Workspace.currIt.Value then local puzz = script.Parent:FindFirstChild("Puzz") puzz.Parent = player.PlayerGui puzz.Adornee = script.Parent.Parent print("Adornee set to "..script.Parent.Parent.Name) print("Puzz cloned into "..player.Name"'s PlayerGui") local list = game.ReplicatedStorage.puzzles:GetChildren() local game = list[math.random(#list)] game:Clone().Parent = puzz print("Minigame cloned") end end game.Workspace.currMap.Changed:connect(moved)

However, my main problem is this, the event doesn't seem to fire(and activate the function), ever. The script will just sit there, no prints, no errors, nothing. I've been thinking that maybe the localscript isn't in the right place and it won't even begin to run it's code, as I've been reading what it states about this on wiki I'm not sure. So, first thing, is this script not in the correct place to run? Secondly, Is the script being in ReplicatedStorage then being copied over to a Character breaking it? Finally, if the second question is correct, how would I "Reboot" the script once it's been copied into a Player's Character?

Really sorry for the long post guys. I just wanted to make sure I've covered every last detail, also as you may see, I'm not the best scripter in the world, so please pardon my awful ways of the almighty LUA. That aside, I am also going to keep trying to fix this(in the next few hours I have available), and will let you guys know(or just delete the thread, if it's no longer useful) if I have any luck with this! (I really need to cut back with how many words it takes me to write something, I just wish I had this skill for my school assessment. XD)

1
You should put localscripts in the Player's backpack or startergui. It could also be possible that currMap is not changing at all. FearMeIAmLag 1161 — 10y
0
Yeah, I've been messing around with seeing if I can move the script, but with the setup I currently have, it could be difficult. And currMap does change, I've checked. :) Thanks for your help though! Jackd44 35 — 10y

Locked by 1waffle1 and evaera

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?