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

Character customization teleports all players to the same place?

Asked by 5 years ago
Edited 5 years ago

So, I made a character customization button on the main menu of the game. When a player clicks "customize" it brings their player and camera to a podium where they can equip accessories, pants, etc to see what they look like. The only problem is, is when I asked my friend to test it with me, it teleported us both to the same podium, so I could see her and she could see me. How would I script it so it works?

script -- (inside customization button)

-- Contstants -- 

local Camera = game.Workspace.CurrentCamera 
local Player = game.Players.LocalPlayer

-- Camera -- 
repeat wait() until Player.Character

script.Parent.MouseButton1Click:connect (function ()
    Camera.CameraType = "Scriptable"
    Camera.CFrame = game.Workspace.CustomizePart.CFrame
    script.Parent.Parent.Menus.Catalog.Visible = true
    script.Parent.Parent.Menus.Quick.Visible = true
    script.Parent.Parent.Menus.Inventory.Visible = true
    script.Parent.Parent.ButtonFrame.Visible = false
    script.Parent.Parent.Spawn.Visible = false
    script.Parent.Parent.CCBack.BackButton.Visible = true
    script.Parent.Visible = false
    if Player.Character and Player.Character:FindFirstChild("UpperTorso") then
        Player.Character.UpperTorso.CFrame = CFrame.new(-17.422, 6.052, 79.815)

        local controls = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
controls:Disable()

end
end)

I understand the script teleports the player to the podium, but how would I make it so other players teleport to different podiums? I have no idea where to start.

0
The clients character's position replicates itself to the server, you you will need to make a work-around to solve that problem. One way you can do it is locally clone a rig from ReplicatedStorage and apply any changes made locally to the client's character (that the server handles, ofcourse). pidgey 548 — 5y
0
@pidgey yeah i have no idea where to start to do that LiLFriks 39 — 5y
0
You will probably need to take a step backwards and learn about remote functions and events. There are lots of guides, even one on here. pidgey 548 — 5y
0
Another solution could be offsetting the position of everything by the number of player's there are in your game. Locally create a new podium for every player, and move that podium and character to each other with an offset. A short example could be: UpperTorso.CFrame = CFrame.new(-17.422, 6.052, 79.815) * CFrame.new(0, 0, 100 * #game.Players:GetPlayers() - 1) pidgey 548 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

easy just put local player = game.Player.LocalPlayers after the mousbutton1click part of the script thing because then it checks wat player clicked the button and only takes the 1 player not all the players

like this:

local Camera = game.Workspace.CurrentCamera

-- Camera --
repeat wait() until game.Players.LocalPlayer.Character

script.Parent.MouseButton1Click:connect (function ()
local Player = game.Players.LocalPlayer
Camera.CameraType = "Scriptable"

AND THEN JUST GO ON WITH YOUR SCRIPT

and now you maybe want to make the player be the only 1 who will see his character so here is the script

script.Parent.MouseButton1Click:connect (function (player)
local players = game.Players
    print(player.Name)
    print(player.Character.Name)
    player.Character.Archivable = true
    local clone = player.Character:Clone()
    clone.Parent = game.Workspace
    print(clone.Name)
    clone.Name = (player.Name .. "'s Clone")

        wait()     
        local selection = Instance.new("SelectionBox")
        selection.Color3 = Color3.new(0.6,0.6,0.6)
        selection.Transparency = 1
        selection.Name = Player.Name.."'s clone"
        selection.Parent = Player.PlayerGui
        wait()
        selection.Adornee = game.Workspace[clone.Name]
        clone:SetPrimaryPartCFrame(CFrame.new(Vector3.new(-26.732, 5.535, -102.696))) --- change to the tp position
        local cframe = clone.PrimaryPart.CFrame 
        clone:SetPrimaryPartCFrame(cframe * CFrame.Angles(0, -30.97, 0)) -- change to the rotate angle

And dont teleport the real player this makes it so it clones the player

And change your script so it edits on the clone and on real the player

And here is a script so it makes all the player CanCollide = False

local PhysicsService = game:GetService("PhysicsService")
local playerGroup = PhysicsService:CreateCollisionGroup("plr")
PhysicsService:CollisionGroupSetCollidable("plr","plr",false)

function NoCollide(model)
    for i,v in pairs(model:GetChildren()) do
        if v:IsA"BasePart" then
            PhysicsService:SetPartCollisionGroup(v,"plr")
        end
    end
end

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(Char)
        Char:WaitForChild("HumanoidRootPart")
        Char:WaitForChild("Head")
        Char:WaitForChild("Humanoid")
        wait(.1)
        NoCollide(Char)
    end)
    if player.Character then
        NoCollide(player.Character)
    end
end)
0
Can you be more specific? Also what would happen to other players that also clicked the customize button? LiLFriks 39 — 5y
0
The character even if changed by a localscript will always replicate to a global state. Vinceberget 1420 — 5y
Ad

Answer this question