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

Trying to make a duplicated part do a tween while moving as a projectile, How to fix?

Asked by 4 years ago

I'm currently trying to develop a sword slice projectile for a game I am working on. I started with no prior scripting experience and am teaching my way along. I've created a button to duplicate my slice and parent it workspace (CFrame will be dealt with at a later stage, for now just trying to run my tween after it duplicates). I have a functional slice in the workspace at the moment that will run its tween as intended when left in the workspace. However, when I duplicate the slice from ReplicatedStorage it does not tween like the original piece. Here is some of the code I'm working with:

FYI The piece in ReplicatedStorage is a duplicated piece of the working slice in the workspace.

Inside of a local script I have this for my spawning button:

local button = script.Parent


local function Firee()
    local player = game.Players.LocalPlayer
    local character = player.Character
    local hmndrootpart = character:FindFirstChild("HumanoidRootPart")
    x = game.ReplicatedStorage.Slice:Clone()
    x.Duped.Value = true
    x.Parent = game.Workspace

    wait(4.8)


end

button.MouseButton1Click:Connect(Firee)

Here I am using the function "Firee" to duplicate my slice and to change the boolean value I put inside it to true for the other script's detection. The button part is functional, however this next script is where I have my little hiccup when it comes to functionality and I need help on.

local Slice = script.Parent
local DupedBool = Slice.Duped
animator = require(script.Parent.Animator)



while DupedBool == true do
    local Slice = script.Parent
    local DupedBool = Slice.Duped
    animator = require(script.Parent.Animator)
    wait(7)
    animator.NewTween:Play()
    wait(3)
    script.Parent.CanCollide = false
end 

(Duped is the BooleanValue stored underneath the Sword Slice projectile as a child)

This script works normally when left to start the game in the Workplace, however, when duplicated there is no tween animation. I have tried switching from a "while do" loop to only using if statements and I'm not sure where to go from here to fix my process here.

Any help would be much appreciated, as I am only a beginner when it comes to these sorts of issues.

0
Place a print right before after the wait(7) and see if that prints. Nckripted 580 — 4y
0
Didn't print. Simply_Nobody 0 — 4y

Answer this question