Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

server script loops doesn't function correctly. how do i use loops in this situation?

Asked by 5 years ago

so basically, i have a localscript that uses a key function to fireserver to a remoteevent. and when this event is recieved from the server script, it is suppose to create a ball that increases sizes then eventually dissapears.

however, with my minimal knowledge of loops, i cannot understand how to do this. can someone tell me what's wrong with this loop script?

SERVER SCRIPT: (this is where the issue lies)

local tEvent = Instance.new("RemoteEvent")
tEvent.Name = "tEvent"
tEvent.Parent = script.Parent.Parent.Parent.ReplicatedStorage

tEvent.OnServerEvent:Connect(function(Player) -- Player who fired the event

    local Character = Player.Character or Player.CharacterAdded:wait()

-- animation

local humanoid = Character.Humanoid

local animation = script.Animation

local animtrack = humanoid:LoadAnimation(animation)
animtrack:Play()

wait(.4)

local swave = Instance.new("Part")
swave.Shape = "Ball"
swave.Size = Vector3.new(3,3,3)
swave.CanCollide = false
swave.Transparency = 0.7
swave.BrickColor = BrickColor.new("Medium blue")
swave.Material = "Neon"
swave.TopSurface = "Smooth"
swave.BottomSurface = "Smooth"
swave.Anchored = true
swave.CFrame = Player.Character.HumanoidRootPart.CFrame*CFrame.new(0, 2, 0)
swave.Parent = workspace

for i = 4, -1, 0 do
    swave.Size = Vector3.new(1,1,1)

end

wait(1)
swave:Destroy()

end)
0
at line 33, make it: for i = 4, 0, -1 do dadysherwin2 155 — 5y
0
yeah, it works but how would i make the ball increase in size? in this situation i cant figure it out. jesusbeef 33 — 5y
0
i suggest putting this script in server script service, because currently the client can access replicated storage and fire that event xXmacerofXx 29 — 5y
0
its already inside the server script service jesusbeef 33 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

oh it think i found the problem. what your doing is using the for loop to change the value of "swave" to (1,1,1) every time it loops, keeping it the same size. your also using the for loop wrong. (x,y,z) x is the value the loop starts from, this should in your case be 4, y is equal to the number the loop will end at, in your case the loop will end when it reaches -1. z is equal to the number it counts up or down by, in your case, this should be -1

for i = 4, 0, -1 do
    swave.Size = swave.Size + Vector3.new(1,1,1)
        wait(0.25)
end
wait(1)
swave:Destroy()

end)
Ad

Answer this question