So I have this stringValue attached to the player indicating that upon dying to the car, the player’s value changes from Human to Soul. I made this script that attaches a chain onto a person if their race value is a Soul. But the script doesn’t work. Please help, thanks
local Race = game.Players.LocalPlayer.PlayerValues.Race.Value
if Race == "Soul" then
local Chains = game.ReplicatedStorage.Chains
Chains.Parent = workspace
Chains = CFrame.new(0.1,-1.6,1)
end
You can actually use the :GetPropertyChangedSignal() event.
For example:
local value = Instance.new("StringValue")
value.Value = "Hello"
wait(5)
value.Value = "World!"
value:GetPropertyChangedSignal("Value"):Connect(function()
if value.Value == "World!" then
print("Hello World!")
end
end)
In your code:
local Race = game.Players.LocalPlayer.PlayerValues.Race
Race:GetPropertyChangedSignal("Value"):Connect(function() --Fires when it notices the "Value" property changed
if Race.Value == "Soul" then --Checks if the value has changed to "Soul"
local Chains = game.ReplicatedStorage.Chains --Does the task
Chains.Parent = workspace
Chains = CFrame.new(0.1,-1.6,1)
end
end)
Thanks for the script. The script works but the chains wouldn’t properly CFrame onto the player. I don’t know why. https://i.gyazo.com/09d723ec682333400fd0b056b5e28830.mp4
(I turned off the kill script for the car by the way)