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

[Fixed]How to increase Y without affecting X and Z?

Asked by 5 years ago
Edited 5 years ago

Before we start: Apologies for the burning of peoples eyes in my previous post, I accidentally added an extra line and the script and text got reversed.

I have created a script that summons a shock wave that will give rise to spikes in 10 locations, they spawn in a format like this Note: ar = shockwave;

earthspike.CFrame = ar.CFrame * CFrame.new(-6,math.random(-40,40),math.random(-40,40) -- 40 is equal to the shockwave radius
--The reason I am putting it in the X position is because of the funky Orientation

they start underground in random locations scattered throughout the shock wave, and will rise above the surface, that's where the trouble is . I want the tween the rising of the spikes without effecting the X or Z. I just want the Y value to increase. But I don't know how to do that. Setting the X and Z values to 0 won't work, all it will do is make the spikes go to those exact coordinates

game.ReplicatedStorage.EarthStomp.OnServerEvent:Connect(function(player)
local char = game.Players[player.Name].Character
    local hum = char.Humanoid
    local root = char.HumanoidRootPart
    local ar = Instance.new("Part")
    local ten = true
    ar.BrickColor = BrickColor.new("Bright green")
    ar.Anchored = true
    ar.CanCollide = false
    ar.Material = Enum.Material.Neon
    ar.Transparency = 0
    ar.Shape = Enum.PartType.Cylinder
    ar.Size = Vector3.new(0.01,1,1)
    ar.CFrame = player.Character["Left Leg"].CFrame + Vector3.new(0.01,0,0)
    ar.Orientation = Vector3.new(0, 0, 90)
    ar.Parent = workspace
    game.Debris:AddItem(ar,10)
    local tween = game:GetService("TweenService")
    local tweenInfo = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
    local tweenProperty = {Size = Vector3.new(0.01,150,150);Transparency = 1}
    local tweenRun = tween:Create(ar,tweenInfo,tweenProperty)
    tweenRun:Play()
    wait(0.5)



function spike()
    earthspike = game:GetService("ServerStorage").Spike:Clone()
    earthspike.Anchored = true
    earthspike.CanCollide = true
    earthspike.Parent = workspace
    earthspike.CFrame = CFrame.new(-6,math.random(-40,40),math.random(-40,40)
    game.Debris:AddItem(earthspike,5)
    local tween = game:GetService("TweenService")
    local tweenInfo = TweenInfo.new(0.01,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
    local tweenProperty = {Orientation = Vector3.new(0,0,0)}
    local tweenRun = tween:Create(earthspike,tweenInfo,tweenProperty)
    tweenRun:Play()

    local tweenInfo2 = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
    local tweenProperty2 = {ar.CFrame * Vector3.new(0,math.random(-40,40),math.random(-40,40))}
    local tweenRun2 = tween:Create(earthspike,tweenInfo2,tweenProperty2)
    tweenRun2:Play()
 end  
for i = 1,10 do
    spawn(spike)
end

earthspike.Touched:connect(function(hit)
local ehum = hit.Parent:findFirstChild("Humanoid") or hit.Parent.Parent:findFirstChild("Humanoid")
    earthspike.BrickColor = hit.BrickColor
    if ehum and ehum ~= hum then
    if not ten then return end
    ehum:TakeDamage(20)
    earthspike:Destroy()
elseif hit.Anchored  == true and hit.CanCollide == true then
wait(2)
end
end)
end)
0
As I said in the last post, you could simply do: Vector3.new(0, someNumber, 0). You basically ignore the X and Z. User#22219 20 — 5y
0
Which is why i said in this post: Setting the X and Z values to 0 won't work, all it will do is make the spikes go to those exact coordinates DominousSyndicate 41 — 5y
0
Then you could add some Vectors like Vector3.new(50, 21, 341) + Vector3.new(0, 34, 0) User#22219 20 — 5y
0
I did CFrame + Vector3.new but new i got an error: "Unable to cast to dictionary" DominousSyndicate 41 — 5y

Answer this question