I tried to create a part where if we touch it it makes the flag turn blue after 5 seconds but this error is coming
script:
local Trigger = script.Parent
local Flag = script.Parent.Parent.Flag
local Pole = script.Parent.Parent.Pole
local cooldown = false
Trigger.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if hit.Parent:FindFirstChild('Humanoid') then
if cooldown == true then
wait(5)
Flag.BrickColor.new = BrickColor.new('Baby blue')
elseif cooldown == false then
Flag.BrickColor.new = BrickColor.new('Really red')
end
end
end)
Flag.BrickColor.new is not a property of BrickColor, though it is a method of the BrickColor API:
local Trigger = script.Parent
local Flag = script.Parent.Parent.Flag
local Pole = script.Parent.Parent.Pole
local cooldown = false
Trigger.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if hit.Parent:FindFirstChild('Humanoid') then
if cooldown == true then
wait(5)
Flag.BrickColor = BrickColor.new('Baby blue')
elseif cooldown == false then
Flag.BrickColor = BrickColor.new('Really red')
end
end
end)
Just remove the .new and it should work.
When you see the error ’ cannot be assigned to’, that means is a read only property, or it doesn’t exist.
local Trigger = script.Parent
local Flag = script.Parent.Parent.Flag
local Pole = script.Parent.Parent.Pole
local cooldown = false
Trigger.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if hit.Parent:FindFirstChild('Humanoid') then
if cooldown == true then
wait(5)
Flag.BrickColor = BrickColor('Baby blue')
elseif cooldown == false then
Flag.BrickColor= BrickColor('Really red')
end
end
end)
Yeah, but do not use wait(), it’s deprecated and overall worse than task.wait(). Look at the task library announcement topic to understand why. Even if you don’t, just use task.wait() over wait().
So what I tried to create is that when the player stands on the part the script will trigger and it should check whether the player is standing for 5 seconds or not
task.wait() and wait() will do the same thing, but task.wait() does it better, so your script should still work. I have to leave very soon so if it doesn’t then I won’t be able to help you.
Yeah, to be exact, task.wait() is much more accurate and if you use it without any set time, it’s much faster. It’s the same as RunService.Heartbeat:Wait().
That’s the big reason to use task.wait(), though I think task.wakt() has better memory usage than wait(), or I am just confusing that with another Roblox method.
EDIT: I am probably mixing up the sleep (task.wait() and wait()) methods with the time method, e.g. tick(), os.time(), and (my favorite)os.clock() since some of them have better memory usage than other ones.
Yeah. task.wait() also respects FPS over 60, so if you’re using a FPS unlocker, it’s gonna wait even faster. But task.wait(1) is actually more accurate than wait(1). Anyways, let’s not go too off-topic.
There’s no post as far as I know, but they’ve said it somewhere, could have been some RDC (I have no idea.), and there’s no confirmed ban on anyone using rbxfpsunlocker.
local Trigger = script.Parent
local Flag = script.Parent.Parent.Flag
local Pole = script.Parent.Parent.Pole
local debounce = false
local toggle = false
Trigger.Touched:Connect(function(hit)
if debounce then
return
end
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
debounce = true
if toggle then
toggle = false
Flag.BrickColor = BrickColor.new('Baby blue')
task.wait(5)
debounce = false
elseif not toggle then
toggle = true
Flag.BrickColor= BrickColor.new('Really red')
task.wait(5)
debounce = false
end
end
end)