hi,so i have a ice spike script, and i dont get why im getting an error,I would be very grateful if someone wrote what was wrong
ServerScriptService.Ice_Trail_Server:38: attempt to perform arithmetic (add) on nil and number
local CS = game:GetService("CollectionService") local RS = game.ReplicatedStorage local NumberOfModel = 3 local Model = {} DistApart1 = 6 DistHeight1 = 3.452 DistApart2 = 5 DistHeight2 = 4.553 DistApart3 = 5 DistHeight3 = 5.57 local FreezeTime = 5 ----- Functions ------ local function IceTrailSpike(Object,PlayerName,PartNum) Object.Touched:Connect(function(hit) Object.CanCollide = true if hit.Parent:FindFirstChild("Humanoid") and not CS:HasTag(hit.Parent, "Freeze"..PlayerName) then CS:AddTag(hit.Parent,"Freeze"..PlayerName) hit.Parent.Humanoid:TakeDamage(10) hit.Parent.HumanoidRootPart.Anchored = true wait(FreezeTime + (0.7*PartNum)) hit.Parent.HumanoidRootPart.Anchored = false end end) end -- Function 2 -- local function IceModelLocation (Player,AttModel,PartCount,DistAdd,RayPos) local HRP = Player.Character:WaitForChild("HumanoidRootPart") local Ice_Location = CFrame.new(HRP.Position) * ( (Model["DistApart"..PartCount]+DistAdd)*HRP.CFrame.LookVector) AttModel.CFrame = CFrame.new(Vector3.new(Ice_Location.X,(RayPos.Y+Model["DistHeight"..PartCount]),Ice_Location.Z))*CFrame.Angles(0,math.rad(HRP.Orientaion.Y),0) AttModel.Anchored = true AttModel.Glow.Anchored = true end -- Remote Event -- RS.Ice_Trail_Att.OnServerEvent:Connect(function(Player) local Debounce = workspace:FindFirstChild("Ice_Trail".. Player.Character.Name) local HRP = Player.Character.HumanoidRootPart local groundDistanceRay = Ray.new(HRP.Position,Vector3.new(0,-500,0)) local Hit, pos = workspace:FindPartOnRay(groundDistanceRay,HRP.Parent) local IceAtt_Group = Instance.new("Model",workspace) IceAtt_Group.Name = "Ice_Trail_Att"..Player.Character.Name local DistAdd = 0 -- Part1 -- CS:AddTag(Player.Character, "Freeze"..Player.Name) for Part = 1,NumberOfModel do local IceModel = RS.Ice_Trail.SPIKE_Model["SPIKES"..Part]:Clone() IceTrailSpike(IceModel,Player.Character.Name) IceModelLocation(Player,IceModel,Part,DistAdd,pos) wait() IceModel.Transparecy = 0.2 DistAdd = DistAdd + Model["DistApart"..Player] end wait(FreezeTime) for Part2 = 1,NumberOfModel do local IceModel = workspace["Ice_Trail_Att_"..Player.Character.Name]["SPIKES"..Part2] local BG = workspace["Ice_Trail_Att_"..Player.Character.Name]["SPIKES"..Part2].BG.Decal local Glow = workspace["Ice_Trail_Att_"..Player.Character.Name]["SPIKES"..Part2].Glow local TweenService = game:GetService("TweenService") local Goal = {} Goal.Transparency = 1 -- Ice Model local tweenInfo = TweenInfo.new(3) local IceTween = TweenService:Create(IceModel, tweenInfo, Goal) -- Background Model local tweenInfo = TweenInfo.new(3) local BGTween = TweenService:Create(BG, tweenInfo, Goal) -- Glowing Model local tweenInfo = TweenInfo.new(3) local GlowTween = TweenService:Create(Glow, tweenInfo, Goal) GlowTween:Play() IceTween:Play() IceModel.CanCollide = false BGTween:Play() wait(0.5) end wait(1) workspace["Ice_Trail_Att_"..Player.Character.Name]:Destroy() for _, object in pairs(CS:GetTagged("Freeze"..Player.Character.Name)) do CS:RemoveTag(object,"Freeze"..Player.Character.Name) end end)
-- Hello there 'o' local HRP = Player.Character:WaitForChild("HumanoidRootPart") local Ice_Location = CFrame.new(HRP.Position) + ( (Model["DistApart"..PartCount]+DistAdd)*HRP.CFrame.LookVector)
-- Hello there 'o' local HRP = Player.Character:WaitForChild("HumanoidRootPart") local Ice_Location = CFrame.new(HRP.Position) * ( (Model["DistApart"..PartCount]+DistAdd)*HRP.CFrame.LookVector)