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

Help with Replicating LocalScripts?

Asked by 9 years ago

This script is supposed to Clone another LocalScript into the player from the ReplicatedStorage. However when the LocalScript is in the player it doesn't work, why not?

teehee = script.Parent
player = game.Players.LocalPlayer

teehee.MouseButton1Down:connect(function()
    local scriptchar = game.ReplicatedStorage.RandChar:Clone()  
    scriptchar.Parent = player
end)

This is the other LocalScript in question.

math.randomseed(tick())

local skinT = {"125", "1030", "18", "119", "106", "5", "0"}
local pantsT = {"http://www.roblox.com/asset/?id=144076759","http://www.roblox.com/asset/?id=7307783"}

local player = game.Players.LocalPlayer
repeat wait() until player.Character
local character = player.Character

local bColors = character:WaitForChild("Body Colors")

local newskin = skinT[math.random(1,6)]     

bColors.HeadColor = BrickColor.new(newskin)
bColors.LeftArmColor = BrickColor.new(newskin)
bColors.RightArmColor = BrickColor.new(newskin)
bColors.TorsoColor = BrickColor.new(newskin)
bColors.LeftLegColor = BrickColor.new(newskin)
bColors.RightLegColor = BrickColor.new(newskin)

local shirt = Instance.new("Shirt",character)
shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=167295776"
shirt.Name = "NewShirt"
coroutine.wrap(function()
character:WaitForChild("Shirt"):Destroy()
end)()

local pant = Instance.new("Pants",character)
pant.PantsTemplate = pantsT[math.random(1,2)]
pant.Name = "NewPants"
coroutine.wrap(function()
character:WaitForChild("Pants"):Destroy()
end)()


local head = character:WaitForChild("Head1")
head.BrickColor = BrickColor.new(newskin)

2 answers

Log in to vote
0
Answered by
drahsid5 250 Moderation Voter
9 years ago

Easy fix! A local script won't run inside of the player

teehee = script.Parent
player = game.Players.LocalPlayer

teehee.MouseButton1Down:connect(function()
    local scriptchar = game.ReplicatedStorage.RandChar:Clone()  
    scriptchar.Parent = player.PlayerGui --It'll run in the playerGui though
end)

Also, if you're not going to reference scriptchar then try this:

game.ReplicatedStorage.RandChar:Clone() .Parent = player.PlayerGui
Ad
Log in to vote
-7
Answered by 9 years ago
teehee = script.Parent
player = game.Players.LocalPlayer
teehee.MouseButton1Down:connect(function()
    local scriptchar = game.ReplicatedStorage.RandChar:Clone() 
    scriptchar.Parent = player
function Loop((--LOOPAMOUNT))
end)

0
Err, I don't see how this really works. PancakeChop 35 — 9y
0
Try it User#9407 0 — 9y

Answer this question