Here is what I have:
local OnTouchSky = game.ServerStorage.SkyChanger
local OnTouchSkyCopy = OnTouchSky:Clone()
function onTouched(hit)
game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui')
OnTouchSkyCopy.Parent = game.Players.LocalPlayer.PlayerGui
script.Parent.Touched:Connect(onTouched)
end
There are no errors and I honestly have no idea what I'm doing wrong. I'm trying to make a script that when you touch a brick, it copies and pastes a LocalScript from ServerStorage into PlayerGui (so the skybox changes)
LocalScript:
if game.Players.LocalPlayer.Name == "Player1" then
b = Instance.new("Sky")
b.Parent = game.Lighting
b.SkyboxBk = "rbxassetid://591058823"
b.SkyboxDn = "rbxassetid://591059876"
b.SkyboxFt = "rbxassetid://591058104"
b.SkyboxLf = "rbxassetid://591057861"
b.SkyboxRt = "rbxassetid://591057625"
b.SkyboxUp = "rbxassetid://591059642"
end
NOTE: I am not sure if the LocalScript isn't working or it just ain't pasting into PlayerGui. Or should it be in StarterGui, it is only able for the local player who touches the brick that changes the skybox, it doesn't change for anyone else. Please help

1 comment
It works, but script.Parent.Touched:Connect(onTouched) needs to be after end. Is there any specific reason for that? Also, now I'm having trouble when the player touches both sky changer brick the scripts stay