#Body painting script doesnt work
1 messages · Page 1 of 1 (latest)
Here's script for reference:
cd = false
script.Parent.Touched:Connect(function(hit)
local Players = game:GetService("Players")
local model = hit.Parent
local hum = model:WaitForChild("Humanoid")
local parts = model:GetChildren()
local speed = script.Parent.Parent.Parent.Gearbox.Speed.Value
if hum and not hum:HasTag("sprayed") and speed ~= 0 and not cd then
hum:AddTag("sprayed")
print("cherry")
cd = true
local ColorVal = script.Parent.Parent["Color monitor"].Value.Value
if ColorVal == 1 then
print("waow")
Players.PlayerAdded:Connect(function(plr)
print("dang")
plr.CharacterAdded:Connect(function(plrchar)
print("wtf")
plrchar["Body Colors"].HeadColor3 = Color3.fromRGB(255,0,0)
plrchar["Body Colors"].LeftArmColor3 = Color3.fromRGB(255,0,0)
plrchar["Body Colors"].RightArmColor3 = Color3.fromRGB(255,0,0)
plrchar["Body Colors"].LeftLegColor3 = Color3.fromRGB(255,0,0)
plrchar["Body Colors"].RightLegColor3 = Color3.fromRGB(255,0,0)
plrchar["Body Colors"].TorsoColor3 = Color3.fromRGB(255,0,0)
end)
end)
(...)
end)```
the (...) stands for the rest of the script, im focusing only on red for better reading
what is red?
ColorVal = 1
from an external value
local ColorVal = script.Parent.Parent["Color monitor"].Value.Value
the random print lines are to see where does it break
so far it only prints until print("cherry"), and the console doesnt really tell me anything either
i meant what is red in terms of what is highlighted or underlined red, but..
what exactly is this? lua local ColorVal = script.Parent.Parent["Color monitor"].Value.Value if ColorVal == 1 then
is it an intvalue? colorvalue? a brickcolor named value with an intvalue named value parented to it and you missed out another .Value in that .Value.Value.Value.Value chain? i'm confuzed
Value(name).value(property)
naming collisions yay 🎨
theres no collisions bc there isnt two children named "value"
and if they were itd appear in my output as an error or warning
why are you connecting players.playeradded in a .touched event? won't this make duplicate connections? lua if ColorVal == 1 then print("waow") Players.PlayerAdded:Connect(function(plr) print("dang")
i probably tried to simulate localscript since im using a serverscript
as far as it only printing until "cherry";
print("cherry") cd = true local ColorVal = script.Parent.Parent["Color monitor"].Value.Value if ColorVal == 1 then print("waow")
it would mean ColorVal is not ==1, you could put a breakpoint in there and look at the Watch variables tab and see what's going on
does the double connection null the whole if clause tho? cuz i did not get a printing of "waow"
i did think of that
stuff like print(ColorVal) for example
reina isn't ColorVal
or did you mean where it says "print("waow")" you changed the waow to "reina"?
no no
i meant i put reina in the color monitor script where the buttons and numbers are initially changed
i also just did ur thing where it prints 1
it did print 1
it printed cherry
but nothing else
if math.round(ColorVal) == 1 then...
you doubt me? 
not rlly i just want an explanation of why round it
floating point imprecision 
0.999 ~= 1.0
just a guess
the condition is failing, if it wasn't then the print would print, so, there aren't exactly many options as to how, assuming it's a numbervalue.value
;p
or rather i did not find the error, as ive consistently scanned the output several times previously
yup
no errors
it wont even tell me what the problem could be or anything
theres isnt anything either on warnings
screenshot output window?
maybe clean some of that up?