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

Spawn color not changing with the script?

Asked by 2 years ago
UserInputService = game:GetService("UserInputService")
local Spawn1 = game.Workspace.SpawnLocation

UserInputService.InputBegan:Connect(function(input, GameProcessedEvent)

local RandomEvent = math.random(1,5)
    if input.KeyCode == Enum.KeyCode.E and RandomEvent == 1 then
        Spawn1 = BrickColor.new("Really red")
    end
    if input.KeyCode == Enum.KeyCode.E and RandomEvent == 2 then
        Spawn1 = BrickColor.new("Baby blue")
    end
    if input.KeyCode == Enum.KeyCode.E and RandomEvent == 3 then
        Spawn1 = BrickColor.new("Gold")
    end
    if input.KeyCode == Enum.KeyCode.E and RandomEvent == 4 then
        Spawn1 = BrickColor.new("Grey")
    end
    if input.KeyCode == Enum.KeyCode.E and RandomEvent == 1 then
        Spawn1 = BrickColor.new("Beige")
    end
end)

Someone could explain why it's not changing colors?

1 answer

Log in to vote
0
Answered by 2 years ago

Set the BrickColor of the spawn not the spawn as a BrickColor

UserInputService = game:GetService("UserInputService")
local Spawn1 = game.Workspace.SpawnLocation

UserInputService.InputBegan:Connect(function(input, GameProcessedEvent)

local RandomEvent = math.random(1,5)
    if input.KeyCode == Enum.KeyCode.E and RandomEvent == 1 then
        Spawn1.BrickColor = BrickColor.new("Really red")
    end
    if input.KeyCode == Enum.KeyCode.E and RandomEvent == 2 then
        Spawn1.BrickColor = BrickColor.new("Baby blue")
    end
    if input.KeyCode == Enum.KeyCode.E and RandomEvent == 3 then
        Spawn1.BrickColor= BrickColor.new("Gold")
    end
    if input.KeyCode == Enum.KeyCode.E and RandomEvent == 4 then
        Spawn1.BrickColor = BrickColor.new("Grey")
    end
    if input.KeyCode == Enum.KeyCode.E and RandomEvent == 1 then
        Spawn1.BrickColor = BrickColor.new("Beige")
    end
end)
Ad

Answer this question