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

Why wont my script wont detect change in a Bool Value?

Asked by 3 years ago
local StarterGui = game:GetService("StarterGui")
local FartButton = StarterGui:WaitForChild("FartButton")
local character = script.Parent
local KillAnim = script:WaitForChild("FartAnim")
local Torso = script.Parent:WaitForChild("LowerTorso")
local UserInputService = game:GetService("UserInputService")
local emitter = Torso:WaitForChild("ParticleEmitter")
local humanoid = character:WaitForChild("Humanoid")
local KillAnimTrack = humanoid.Animator:LoadAnimation(KillAnim)
local sound = script:WaitForChild("FartSound")
local Head = script.Parent:WaitForChild("Head")
local Neutral = Head:WaitForChild("face")
local Grit = Head:WaitForChild("face2")


local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Fart = ReplicatedStorage:WaitForChild("Fart")
local FartVal = Fart.Value


while true do
    if FartVal == true then
        print("Fart was Pressed!")
        Neutral.Transparency = 1
        Grit.Transparency = 0
        emitter.Rate = 8
        humanoid.JumpPower = 200
        humanoid.WalkSpeed = 34
        KillAnimTrack:Play()
        sound:Play()
        wait(2)
        humanoid.WalkSpeed = 16
        humanoid.JumpPower = 50
        emitter.Rate = 0
        Neutral.Transparency = 0
        Grit.Transparency = 1
    end
end

I was wondering if i could get some help with this.

(I've also tried using ":GetPropertyChangedSignal" and it still doesn't work.)

0
All the contents of StarterGui are replicated into PlayerGui located in the client's player object this applies to all starter services MarkedTomato 810 — 3y
0
changing things in StarterGui, Starterpack, StarterPlayer, StarterCharacterScripts and StarterPlayerScripts will do nothing MarkedTomato 810 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

you cant put FartVal as a variable...

u kinda have to do if Fart.Value == true then ....

0
Still doesn't seem to work, are there any other solutions you know of? sharkingaround 0 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

It seems that "GetPropertyChangedSignal" worked for this, i was just doing it wrong.

local StarterGui = game:GetService("StarterGui")
local character = script.Parent
local KillAnim = script:WaitForChild("FartAnim")
local Torso = script.Parent:WaitForChild("LowerTorso")
local UserInputService = game:GetService("UserInputService")
local emitter = Torso:WaitForChild("ParticleEmitter")
local humanoid = character:WaitForChild("Humanoid")
local KillAnimTrack = humanoid.Animator:LoadAnimation(KillAnim)
local sound = script:WaitForChild("FartSound")
local Head = script.Parent:WaitForChild("Head")
local Neutral = Head:WaitForChild("face")
local Grit = Head:WaitForChild("face2")


local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Fart = ReplicatedStorage:WaitForChild("Fart")

Fart:GetPropertyChangedSignal("Value"):Connect(function()

    if Fart.Value == true then
        Fart.Value = false
        Neutral.Transparency = 1
        Grit.Transparency = 0
        emitter.Rate = 8
        humanoid.JumpPower = 200
        humanoid.WalkSpeed = 34
        KillAnimTrack:Play()
        sound:Play()
        wait(2)
        humanoid.WalkSpeed = 16
        humanoid.JumpPower = 50
        emitter.Rate = 0
        Neutral.Transparency = 0
        Grit.Transparency = 1
    end

end)

Answer this question