I was thinking about how could i run a event in which case at a specific amount of points it will spawn a certain item in a specific place
For example, when u get 10 points it will spawn a part on top of you. Note that the game will be played by only one player per server. Can you guys give me some ideas
Ok, I’m not such a scripter either, but I do know that if u want to ask for help, you gotta’ come with atleast one part of the script, you can’t turn up with no script asking for someone to make one for you
Assuming you are using values you can probably use the .Changed event to track it, also you should probably supply a general idea of what you are trying to do.
I was thinking about using GetPropertyChangedSignal
where a function runs everytime it’s updated. Here’s an example:
value:GetPropertyChangedSignal("Value"):Connect(function() -- // Runs everytime it's updated
if value.Value >= 10 then -- // Checks value
local newPart = Instance.new("Part") -- // Create Part
end
end)
value.Changed:Connect(function(newValue)
if newValue >= 10 then
local newPart = Instance.new("Part")
end
end)
You should use .Changed
instead.
https://developer.roblox.com/en-us/api-reference/event/IntValue/Changed
You could use .Changed
, it still works, but if you want the latest use, you could use :GetPropertyChangedSignal("Value")
. You could also use it and see if anything other properties have changed, such as color properties.
Refer to the code snippet I provided to see why you should use .Changed
instead of :GetPropertyChangedSignal()
for ValueBase instances.
You should also read through the documentation article as well.
Yeah, I know that the .Changed
event is more “simpler”, however, I’m recommending this idea to run anything if any property is changed. I would suggest using .Changed
, but you have more diversity with :GetPropertyChangedSignal
.
There’s no point in saying that .Changed
function is superior.
Nothing to do with it being simpler.
For ValueBase instances the .Changed
RBXScriptSignal object only fires when its “Value” property changes. Additionally, unlike the .Changed
RBXScriptSignal object for other instances, its parameter represents the value property’s new value.
It is contextually superior in this circumstance.