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

How do I change the skybox for only a specific client after touching a part to trigger it?

Asked by 4 years ago

any idea why my local script is changing everybody's skybox instead of only the player who touches the part? this is a LocalScript in StarterCharacterScripts

local skybox = game:GetService("Lighting").Sky

game.Workspace.SkyboxTriggers.LotL.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player ~= nil then
        skybox.SkyboxUp = "rbxassetid://6115435142"
        skybox.SkyboxDn = "rbxassetid://6115431284"
        skybox.SkyboxBk = "rbxassetid://6115432902"
        skybox.SkyboxFt = "rbxassetid://6115433855"
        skybox.SkyboxLf = "rbxassetid://6115430469"
        skybox.SkyboxRt = "rbxassetid://6115432137"
        end    
    end
end)

When the player touches the Part called "LotL" the skybox changes as intended, but for every player. The server does not see this change.

1 answer

Log in to vote
0
Answered by 4 years ago

Use A Remote Event To Change The Sky Box For That Player.

Script 1:

    game.Workspace.SkyboxTriggers.LotL.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") then
            local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player ~= nil then
game.ReplicatedStorage:FindFirstChild("EventName"):FireClient(player)
            end   
        end
    end)

Local Script 2:

local skybox = game:GetService("Lighting").Sky

      game.ReplicatedStorage:FindFirstChild("EventName").OnClientEvent:Connect(function()
            skybox.SkyboxUp = "rbxassetid://6115435142"
            skybox.SkyboxDn = "rbxassetid://6115431284"
            skybox.SkyboxFt = "rbxassetid://6115433855"
        skybox.SkyboxLf = "rbxassetid://6115430469"
        skybox.SkyboxRt = "rbxassetid://6115432137"
            end   
        end
    end)
0
Finally...thank you. I was stuck on this for an entire day. You're a lifesaver. Omenoire 11 — 4y
Ad

Answer this question