Currently im working on an standing game, but i cant achieve “standing points”, i want to make an part that would give player points when standing. (Something similar to [Green] Stand Still Simulator - Roblox).
I already tried using scripts from How to give points when standing on a part? but it only gaved points when i was walking on part. If yall could give some examples it would be good too!
Simply keep giving the player points until they stop, using Touched and TouchedEnded. Make use of Players:GetPlayerFromCharacter to make sure it’s a player, not NPC. You can constantly keep giving them points using a while loop, though, probably is a better way. Since while loops don’t stop, use
while StandingValue == true do
Could you send the script that gave points while walking on a part?
maybe this would help:
local part = script.Parent
local function onPartTouched(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
leaderstat +1 -- clearly not leaderstat, but referencing to your leaderstat you want to add to
end
end
part.Touched:Connect(onPartTouched)
if it’s not working, then i don’t know anymore.
1 Like
well, i figured out that script gives you points when standing on a part.
To expand on @OutrageousCode’s script:
local part = script.Parent
part.Touched:Connect(function(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
humanoid.Running:Connect(function(getSpeed)
if getSpeed <= 0 then
leaderstat + 1 -- clearly not leaderstat, but referencing to your leaderstat you want to add to
end
end)
end
end)
3 Likes
yea,this method is working too.
local run = game:GetService("RunService")
local players = game:GetService("Players")
local part = script.Parent
local debounce = false
local touching = false
part.Touched:Connect(function(hit)
if debounce then
return
end
local hitModel = hit:FindFirstAncestorOfClass("Model")
if hitModel then
local hitPlayer = players:GetPlayerFromCharacter(hitModel)
if hitPlayer then
local hitHuman = hitModel:FindFirstChildOfClass("Humanoid")
if hitHuman then
touching = true
while true do
run.Stepped:Wait()
if touching then
if hitHuman.MoveDirection.Magnitude == 0 then
debounce = true
hitPlayer.leaderstats.Score.Value += 1 --Example leaderstat.
task.wait(1)
debounce = false
else
break
end
else
break
end
end
end
end
end
end)
part.TouchEnded:Connect(function()
touching = false
end)
This works well (I’ve tested).
2 Likes
Yea it works perfectly fine and is more improved than the other ones