game.Workspace.Value.Value.Changed:Connect(function()
local b = game.Players.LocalPlayer:WaitForChild("Character")
b.HumanoidRootPart.Anchored = false
print("Unchored")
end)
my script says "attempt to index number with changed" in the errors, what is wrong?
2 answers
So there are a few things id like to point out
Errors
.1 as kanyeweasftd said, the b between character and hrp.
.2 your trying to index a the number VALUE with Changed, you dont do that, you have to connect .Changed with the instance not the value, do this:
game.Workspace.Value.Changed:Connnect(function()
end)
Tips to make your code look better
Variables
Start using more variables your code is very messy.
Non sense
Why are you waiting for child character? Do this instead
local Players = game:GetService("Players")
local Player = game.Players.LocalPLayer
local Character = Player.Character or Player.CharacterAdded:Wait()
Functions Using local functions there would make your code better, something like this
local function OnValueChange(NewValue)
--your code
end
Value.Changed:Connect(OnValueChange)
Comments Its always good to make yourself a "comment template"
--// Services
--// Librarys
--// Constants
--// Functions
1 comment
check my answer, there has been a problem
@CaioAlpaca I have Tried 2 scripts first one being
game.Workspace.Value.Changed:Connect(function() local Players = game:GetService("Players") local Player = game.Players.LocalPLayer local Character = Player.Character or Player.CharacterAdded:Wait() Character.HumanoidRootPart.Anchored = false print("Unchored") end)
Second one being
local function OnValueChange(NewValue) local Players = game:GetService("Players") local Player = game.Players.LocalPLayer local Character = Player.Character or Player.CharacterAdded:Wait() Character.HumanoidRootPart.Anchored = false print("Unchored") end game.Workspace.Value.Changed:Connect(OnValueChange)
These Have Both failed
4 comments
dont define the variables inside of the changed function, also any errors in output?
nope
Also Which Script are you referring to?
Is it a local script?
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Maybe it's to do with the random "b" in between ("Character") and HumanoidRootPart?
Please use codeblocks, and describe your problem better. This site isn't just "whats wrong fix my code", it's supposed to be a learning experience.