I am coding an obby game, but I encountered an issue. My shrinking platform is shrinking for all players when touched which is an issue when in a large server. I'm confused as all of the code is inside of a LocalScript inside of the StarterPlayerScripts. How could I change my code or use a different method to get the effect to only show up on the client side?
local CollectionService = game:GetService("CollectionService")
local TweenService = game:GetService("TweenService")
for _, ShrinkingPlatform in pairs(CollectionService:GetTagged("ShrinkingPlatform")) do
local debounce = true
local OriginalSize = ShrinkingPlatform.Size
local ShrinkTime = ShrinkingPlatform.ShrinkTime.Value
local RespawnTime = ShrinkingPlatform.RespawnTime.Value
ShrinkingPlatform.Touched:Connect(function(hit)
if debounce ~= false and hit.Anchored ~= true then
debounce = false
local TweeningInfo = TweenInfo.new(ShrinkTime, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
TweenService:Create(ShrinkingPlatform, TweeningInfo, {Size = Vector3.new(0, 0, 0)}):Play()
wait(RespawnTime + ShrinkTime)
ShrinkingPlatform.Size = OriginalSize
debounce = true
end
end)
end
Feel free to ask any questions!
