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:
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.
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.
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.
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.