Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doesn't my script change anything?

I made an ability chooser, and when you choose something, it changes a numbervalue to a certain number, which it does, and the script is supposed to change what happens when you press Q because of this value, but it doesn't change at all. Help would be nice.

local pow = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("PowerGui2"):WaitForChild("Frame")
local ability = pow.Power.Value

local plr = game.Players.LocalPlayer.Character
local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(inputObject, gameProcessed)
    if inputObject.KeyCode == Enum.KeyCode.Q and ability == 1 then
            game.ReplicatedStorage.Speedparticle:Clone().Parent = game.Players.LocalPlayer.Character:FindFirstChild("UpperTorso")
            game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").WalkSpeed = 40
            wait(10)
                game.Players.LocalPlayer.Character:FindFirstChild("UpperTorso").Speedparticle:Remove()
            game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").WalkSpeed = 16
        end

local RS = game:GetService("ReplicatedStorage")

local remoteEvent = RS:WaitForChild("RemoteEvent")

UIS.InputBegan:Connect(function(inputObject, gameProcessed)
    if inputObject.KeyCode == Enum.KeyCode.Q and ability ==2 then
        remoteEvent:FireServer() --Nothing passed to the server
						wait(0.5)
		for i, Child in pairs(plr:getChildren()) do
			if Child:IsA('Part') or Child:IsA('MeshPart') or Child:IsA('Accessory') then
				Child.Transparency = 0.5
			end
		end	
		plr:FindFirstChild("Head").face.Transparency = 0.5
		plr:FindFirstChild("HumanoidRootPart").Transparency = 1
		wait(9.5)
		for i, Child in pairs(plr:getChildren()) do
			if Child:IsA('Part') or Child:IsA('MeshPart') or Child:IsA('Accessory') then
				Child.Transparency = 0
			end
		end	
			plr:FindFirstChild("Head").face.Transparency = 0
		plr:FindFirstChild("HumanoidRootPart").Transparency = 1
    end
end)

1 answer

✓ Accepted answer

You've written local invisvalue = guis:WaitForChild("Invisval").InvisValue.Value, which gets the value of the BoolValue and not the BoolValue itself. When you change the value from another script, this variable stays the same. It's the same as writing local invisvalue = false; it no longer refers to the BoolValue object.

Instead, keep the reference to the BoolValue object instead of its initial value, and check what the Value property is on line 22: and invisvalue.Value == true instead of and invisvalue == true.

1 comment

0

I changed my question a bit but that was the problem and you fixed it! Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.