You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to achive when a player stands on a button the script keeps giving points to the player until the player walks off
What is the issue?
The script only gives cash when the player walks on the part and not just stand
What solutions have you tried so far?
I couldn’t find anything that helps
CODE:
local repStorage = game:GetService("ReplicatedStorage")
local Events = repStorage:FindFirstChild("Events")
local AddCash = Events:FindFirstChild("AddCash")
script.Parent.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
local player = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent)
repeat
player.Stats.Cash.Value += 1 * player.Stats.Rebirths.Value
until script.Parent.TouchEnded
end
end)
TouchEnded is an event, not a bool property. Try this instead:
script.Parent.Touched:Connect(function(hit)
local character = hit.Parent
local humanoid = character:FindFirstChildOfClass("Humanoid")
local player = game.Players:GetPlayerFromCharacter(character)
if not (character and humanoid and player) then return end
local touchHasEnded = false
script.Parent.TouchEnded:Once(function() touchHasEnded = true end)
wait(1)
repeat
player.Stats.Cash.Value += 1 * player.Stats.Rebirths.Value
wait(1)
until touchHasEnded
end)