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

Problems trying to replace character model on touch of external part?

Asked by 5 years ago
Edited 5 years ago

*I've been having some trouble trying to replace my character model with "StarterCharacter" which is stored in ServerStorage. I've tried to destroy the character model and replace it with StarterCharacter, yet the following shows up in my output:

23:08:35.005 - Attempt to connect failed: Passed value is not a function 23:08:35.006 - Stack Begin 23:08:35.006 - Script 'Workspace.TestMount.Script', Line 7 23:08:35.007 - Stack End 23:08:35.007 - Something unexpectedly tried to set the parent of mine4craftia1 to NULL while trying to set the parent of mine4craftia1. Current parent is Players. 23:08:35.464 - attempt to call a nil value 23:08:40.020 - Infinite yield possible on 'Players.mine4craftia1:WaitForChild("ExpNeeded")' 23:08:40.219 - Infinite yield possible on 'Players.mine4craftia1:WaitForChild("PlayerScripts")'

This is the script I tried to run in order to replace the character on touch of the "mount" part:

local mount = script.Parent

    game.Players.PlayerAdded:connect(function(Player)
        local character = game.Players.ChildAdded:wait()
        print(character.Name)

    if mount.Touched:connect(character) then
        local SS = game.ServerStorage
        local RS = game.ReplicatedStorage
        character:Destroy()
        wait()
        SS.StarterCharacter:Clone(RS)

    end


end)

In ReplicatedStorage, I've stored the current player model which is loaded on startup. I tried using the current script I use to load the mount model, stored in ServerStorage, however, the script above completely locks the player from movement and disables your camera, despite loading in the player model.

The custom model script is as follows:

game.Players.CharacterAutoLoads = false
local loadChar = require(game.ServerScriptService.Modules.LoadChar);

game.Players.PlayerAdded:connect(function(plr)

    loadChar(plr,game.ReplicatedStorage,"StarterCharacter")

end)

I'm really stuck on what to do, and cannot put my finger on it. I'm fairly new to scripting and haven't really tackled an issue like this prior, and I could really do with some help. If you're able to figure this out, I thank and applaud you greatly.*

^^^ Everything above has been solved, however, I am still getting some issues when it comes to loading in the players custom model. The current script I've found which works (in destroying the characters model, and cloning the new model into replicated storage) is as follows:



script.Parent.Touched:connect(function(scrpt) local mount = scrpt.Parent local player = game.Players.LocalPlayer local SS = game.ServerStorage local RS = game.ReplicatedStorage local StaChar = SS.StarterCharacter local PlayerPos = player.Character.HumanoidRootPart.Position if game.Players:GetPlayerFromCharacter(mount) then print("Mount touched") print (PlayerPos) player.Character:Destroy() RS.StarterCharacter:Destroy() local ClonedChar = StaChar:Clone() ClonedChar.Parent = RS player:LoadCharacter(PlayerPos) end end)

I've tried loading in the character into the players previous position, yet the custom character does not load in, however the users actual character model load in, and does not spawn at the players previous location. I'm once again puzzled at why this happens, and I don't know what to do about it. If you have any idea, please help out, I could really use it.

Just a note to consider, this script replys on the "Custom model script", which replaces the users model with "X" model ("X" being the custom model).

0
Lots of deprecated code. Where do you learn? User#19524 175 — 5y
0
Personally, I just play around with code, and when I struggle doing something I search it up and try use that to solve my problem. I watch videos and browse the dev forums. However, this is so specific in what I want it to do, I wasnt able to find much to help. mine4craftia1 0 — 5y

Answer this question