"Fly"(Local Script) is not a valid member of Player model

Hello, Im pretty much new to scripting, only working on morphs so far and I came across this issue where my friend gave me a fly script and I tried inserting it into one of my morphs. Apparently the Script needs to be inside the player model in workspace. I did try a few things and this is how it looks like so far

image

the error here seems to be that the script inside the fly script, which apparently is vital to its functinality gives this error!

Error

im not sure what I am suppose to do right now.

try using player.CharacterAdded:Wait()

wouldn’t work as it is a morph. in other words the scripts are only placed in the character when he touches the morphs ā€œplateā€

There’s not really a necessary to reference the Player via using script.Parents often

You could just reference the Player using the GetPlayerFromCharacter function the moment you call your onTouch function

Also I’d suggest adding a ā€œdebounceā€ to prevent the script from firing multiple times at once:

local DB = false
local WS = workspace.Superman.Morph.Head
local RP = WS.GuiMain.Frame.Abilities

function onTouch(hit)
    local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if Player and not DB then
        DB = true
        local Character = hit.Parent

        local r = RP.Fly:Clone()
        r.Parent = Character
        wait(1)
        DB = false
    end
end

--Connect your function to what event you want to detect
1 Like

thank you, it worked, saved my day

Glad it worked! If it did, do make sure to mark the post as a solution! :wink: