How do I change a value in a script?
local value = script.Parent.BillboardGui.TextLabel.Value
script.Parent.Touched:Connect(function(hit)
if hit.Parent.Name == "Enemy" then
value.Value = value.Value - 10
end
end)
How do I change a value in a script?
local value = script.Parent.BillboardGui.TextLabel.Value
script.Parent.Touched:Connect(function(hit)
if hit.Parent.Name == "Enemy" then
value.Value = value.Value - 10
end
end)
What’s the error? Does it downgrade the value if hit from “Enemy”? Does the code underneath run if the parent’s name is “Enemy”?
Send a picture of your explorer? You might have the wrong path or something. And also send error logs.
Nothing prints in the output
and if its called enemy it would print something like hello world
Try debugging it:
script.Parent.Touched:Connect(function(hit)
print(hit.Name, hit.Parent.Name)
if hit.Parent.Name == "Enemy" then
print("enemy touched")
value.Value -= 10
end
end)
That retrieves the Instance
- he’s doing it correctly, as he’s achieving the .Value
from Value
(an instance).
Value is the name of the value set by roblox
oh nevermind I see now i dont get whats wrong.