Value is not being referenced by a script

I made a post similar to this a couple of days ago but that one was vauge and didn’t really highlight the main issue. So i want this chunk of code to refer to the boolean value in the players character:

local playerRagdoll = char:WaitForChild("Ragdolled")

playerRagdoll.Changed:Connect(function()
	print("Value changed")
end)

This is where the script and the value is:
image

The event above is never called even though the value of the Boolean is being manually changed by me and I really want to know if I’m doing something wrong. The script itself is located in the starter character script.

image

The reason it doesn’t fire is because you’re changing the value on the client, meaning this doesn’t get replicated to the server. Seeing as the code block above is contained within a “script” and not a “localscript” the event won’t fire, since it never changed to begin with.

To test this: try going into studio test mode and clicking the “Current: Client” button, this should switch you to the server’s perspective. Try changing the value from the server and see if the event fires.

image

2 Likes

Put this in a LocalScript inside StarterPlayerScripts:

local Player = game.Players.LocalPlayer

local playerRagdoll = Instance.new("BoolValue")
playerRagdoll.Name = "Ragdolled"
playerRagdoll.Parent = Player

playerRagdoll:GetPropertyChangedSignal("Value"):Connect(function()
    print("Value changed to "..playerRagdoll.Value)
end)

Delete the Ragdolled instance and the RagdollHandler script.

This creates the value automatically, so don’t worry about making a new value.

The value is held in the player Character. Does having it in the player or the character change anything? Also all of the code should be handled by the server.

I have tried this and it didn’t work but i can try again with newer code. Ill tell you if anything has changed.

Edit: The value change is being printed. Let me fix my code and ill make your answer the solution. Thanks!

There isn’t any difference, because the Character is the physical appearance, but as player is the digital appearance, think of it as the backend code of a website, and the character is the interface, text, etc.

I prefer to store it in player though.

I know and realistically, player would be the best option but imp lazy and would prefer to have it in the character. Fits in there better too.

Has the script worked then? Did you end up putting it into character?