#property change help

1 messages · Page 1 of 1 (latest)

neon ridge
#
    if BoolValue.Value == true then
        game.Lighting.TimeOfDay = 12
        music.SoundId = Music
        music:Play()
        gui.Visible = true
        GuiClone.TextLabel.Visible = true
    end
    
    print("work!")

    if BoolValue.Value == false then
        game.Lighting.TimeOfDay = 6.5 
        music.SoundId = ambience.SoundId
        music:Play()
        gui.Visible = false
        GuiClone.TextLabel.Visible = false
    end
    
    music:Play()
end

local function onChanged2(plr)
    local CC = Character.HumanoidRootPart.Position
    GuiClone.TextLabel.Text = math.round(CC.X)..", ".. math.round(CC.Y)..", ".. math.round(CC.Z)
end

onChanged()
onChanged2()
BoolValue.Changed:Connect(onChanged)
Character.HumanoidRootPart:GetPropertyChangedSignal("Position"):Connect(onChanged2)```
#

what did i do wrong?

#

the property change for position isn't working

final eagle
#

I'm not the best scripter, so I'll try my best. What do you want to achieve with this?

#

I get the changing time of day and playing music, but what do you need humanoid position for?

supple island
#

what's the goal here + what's outputting + what's not working

neon ridge
neon ridge
supple island
#

any output at all?

final eagle
#

I've never had a good time with instance.Changed

#

Changed is the value right? Or the children

neon ridge
supple island
final eagle
#

Yeah that's your problem

#

Your using changed on the boolvalue

#

Or wait

#

Can you even use it on the value

#

Nevermind ignore that

supple island
#

wait a second, what even IS BoolValue?

#

oh

#

this is a fraction of the script

final eagle
#

Are you changing the value?

supple island
#

its probably the BoolValue instance

final eagle
#

Or is the error the himanoidrootpatt itself?

supple island
#

try this: put print("this") at the start of the first function and print("that") at the start of the second function

#

this can help you pinpoint the issue

final eagle
#

Why are you using getpropertychange signa

#

?

#

Right now you are checking if the value is changed, if that is true you then check if the humanoidrootpart.position has changed

supple island
#

also you dont need to do
if bool == true then
code
end
if bool == false then
code
end

you can instead do

if bool == true then

else

end

final eagle
#

Why not do humanoidrootpart.cframe or position instead

supple island
final eagle
supple island
#

wont fix the issue but its nice

final eagle
#

You aren't checking position

#

That is just a string

#

That's the problem

#

Getpropertysignalchanged uses strings and is overall a different solution to instance.changed

#

Also

#

In both of your local functions you have parameters

#

Both of those parameters aren't fulfilled

#

You execute them without specifying the player

#

But that doesn't really matter since you don't use it

neon ridge
final eagle
#

Yeah no I noticed that

#

Are you checking for the position or if it has changed?

neon ridge
#

also the print only fires once

final eagle
#

Are you checking if it has changed during the time the bool hasn't changed? Or only if the bool has changed

#

Because the bool.changed is instant it doesn't wait for the humanoidrootpart

neon ridge
final eagle
#

Your not changing the value with that

#

Sorry i misread it as a function but your not changing the book in the second function

#

Bool

#

Autocorrect

neon ridge
final eagle
#

Alright my bad

#

Property changed signal uses strings though

#

Yeah no

#

Propertychanged doesn't read positions of psychics

#

Or*

#

You have to use a different event or function

neon ridge
final eagle
#

You could use render stepped or heartbeat and set the old position as variable, if the position doesn't match in the loop then it's detected

#
RunService.Stepped:Connect(function()
    if part.Position ~= oldPosition then
        print("Position changed!")
        oldPosition = part.Position
    end
end)   ```
#

This for example

neon ridge
#

RunService.RenderStepped:Connect(onChanged2)

#

i just used this

final eagle
#

Alright

#

Good luck with your game

supple island
#

or you could do HumanoidRootPart.Changed to use up less recources

dim spade
neon ridge
dim spade
supple island
#

ah

neon ridge
dim spade
#

Cframe.Position is the same as Position

#

Runservice was the next best thing

neon ridge
#

oh okay i understand, thank you

neon ridge
dim spade
#

But you can’t attach an event to a player’s position to fire code when they move because the position changing is physics based

neon ridge
#

playing around is my favorite way to learn scripting

neon ridge
# dim spade But you can’t attach an event to a player’s position to fire code when they move...
    local DogPos = Vector2.new(Dog.position.X, Dog.position.Y)
    local ShadowPos = Shadow.Position
    local SunPos = Vector2.new(Sun.position.X, Sun.position.Y)
    local Direction = DogPos - SunPos
    local Str = 2
    
    local NeoPos = DogPos + Direction * Str
    print(DogPos, ShadowPos, SunPos, Direction, Str, NeoPos)
    ShadowPos = UDim2.new(NeoPos.x, 0, NeoPos.y, 0)
    
end``` im sorry to bother again but could you tell me why this isn't working?
all the positions stay the exact same
dim spade
#

^udim2 documentation

neon ridge
# dim spade if sun and shadow are UI objects, they use UDim2 not Vector2 for size and positi...
    local ShadowPos = Shadow.absolutePosition
    local Str = 2


    local DogPos = Vector2.new(Dog.Position.X.Offset, Dog.Position.Y.Offset)
    local SunPos = Vector2.new(Sun.Position.X.Offset, Sun.Position.Y.Offset)

    local Direction = (DogPos - SunPos)
    local Direction2 = Vector2.new(Direction.X, Direction.Y)

    local NeoPos = DogPos + Direction2 * Str
    print(NeoPos, DogPos)
    Shadow.Position = UDim2.fromOffset(NeoPos.X, NeoPos.Y)

end``` i can't get it to work
#

i mean it works but the shadow isn't behind the dog

#

its completly off

#

instead of it slightly being behind the dog its like way off

#

the dog's position isn't the dogs position for some reason trying to make the dogs position the dogs position i got from the same dog makes it different

dim spade
#

what are you trying to accomplish

neon ridge
#

guis are so confusing

dim spade
#

So it's a volume slider for jumpscares?

#

where do the dog and shadow come in

#

is the dog below the sun and you want the dog to be between the shadow and the sun

neon ridge
# dim spade where do the dog and shadow come in

the sun has a ui drag detector, basically i wanted to make it a bit weird by it being 1 on the sides making the dog have a shadow so left or right but when its right above it would be 0, but i can't even get the visual to work its completly off

#

i just don't understand it, with script, without script

dim spade
#

can you move the UI a bit to show me where the shadow, dog, and sun should be when the slider is at max vs min

#

just manually

neon ridge
#

and the shadow would be facing the opposite direction of the shadow

dim spade
# neon ridge like this, min, max, max

that's pretty tricky, what I would try is:
if the sun is all the way to the left, its x offset is 0, and it's 1 all the way to the right. If it's not, set it up that way.

Put the shadow in a frame such that if it's all the way to the right, its x offset = 1, and if it's all the way to the left, its x offset = 0.

set the shadow's x offset to -(sun's x offset), this way if the sun is all the way to the right of its frame the shadow will be all the way to the left of its frame, and vice versa.

#

my bad, set the shadow's x offset to (1 - sun's x offset), not -(sun's x offset)

#

that way if the sun's x offset is 1 the shadow's is 0, and vice versa

neon ridge
dim spade
#

so at runtime your dog is changing positions?

#

ctrl + shift + f and search anything referencing dog.Position

neon ridge
#

i think im very close to just giving up man

dim spade
neon ridge
#

how the hell

#

    local DogPos = Dog.AbsolutePosition
    local SunPos = Sun.AbsolutePosition
    
    print(DogPos)

    local Direction = DogPos - SunPos

    local Str = 2 
    local NeoPos = DogPos + Direction * Str
    
    Shadow.Position = UDim2.fromOffset(NeoPos.X, NeoPos.Y)
end




Sun.Changed:Connect(MegaMathMunch)```
i got the dog itself to sit still but not its shadow
dim spade
#

thats the ui object, be warned the code is not very neat

#

free commission evilcat

neon ridge
#

i can't open it

dim spade
#

rbxl's are full games

neon ridge
#

i got it

#

thank you