#Body painting script doesnt work

1 messages · Page 1 of 1 (latest)

fast ember
#

I tried print debugging but the output doesnt help me out

#

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

fast ember
#

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

hoary wigeon
#

i meant what is red in terms of what is highlighted or underlined red, but..

hoary wigeon
fast ember
#

its a numbervalue

#

if u press a red button, the value instance is set to 1

hoary wigeon
#

why is .Value.Value twice?

#

shouldn't it be only once?

fast ember
#

Value(name).value(property)

hoary wigeon
#

naming collisions yay 🎨

fast ember
#

theres no collisions bc there isnt two children named "value"

#

and if they were itd appear in my output as an error or warning

hoary wigeon
#

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")

fast ember
#

i probably tried to simulate localscript since im using a serverscript

hoary wigeon
fast ember
#

does the double connection null the whole if clause tho? cuz i did not get a printing of "waow"

hoary wigeon
#

stuff like print(ColorVal) for example

fast ember
#

i put "reina" as a trigger when u press red and set it to 1

#

and it did print reina

hoary wigeon
#

reina isn't ColorVal

hoary wigeon
fast ember
#

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

hoary wigeon
fast ember
#

what

#

i put no decimals why add round function?

hoary wigeon
fast ember
#

not rlly i just want an explanation of why round it

hoary wigeon
#

0.999 ~= 1.0

fast ember
#

oh god...

#

not that thing 😭 i didnt even consider it

#

lemme try

hoary wigeon
#

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

fast ember
#

um

#

it didnt print nothing either 😭

hoary wigeon
#

maybe u got error then

#

check output window

#

otherwise if(true) lol

fast ember
#

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

hoary wigeon
#

screenshot output window?

fast ember
#

uhhh

#

its too big 😭

#

lemme try to expand it

hoary wigeon
#

maybe clean some of that up?