kanapuro
(wanderer)
#1
portion of server side script
FelineParent = script.Parent
-- MORPH --
game.Players.PlayerAdded:Connect(function(plr)
game.ReplicatedStorage.MorphEvent.OnServerEvent:connect(function(plr)
local oldCharacter = plr.Character
local newCharacter = FelineParent.Feline:Clone()
newCharacter.HumanoidRootPart.Anchored = false
newCharacter:SetPrimaryPartCFrame(oldCharacter.PrimaryPart.CFrame)
plr.Character = newCharacter
newCharacter.Parent = workspace
end)
end)
local script (in textbutton)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
script.Parent.MouseButton1Click:Connect(function()
ReplicatedStorage.MorphEvent:FireServer()
end)
1 Like
Katrist
(Katrist)
#2
Why are you connecting the .OnServerEvent every time a player joins? Probably what’s causing your bug.
Code:
FelineParent = script.Parent
-- MORPH --
game.ReplicatedStorage.MorphEvent.OnServerEvent:connect(function(plr)
local oldCharacter = plr.Character
local newCharacter = FelineParent.Feline:Clone()
newCharacter.HumanoidRootPart.Anchored = false
newCharacter:SetPrimaryPartCFrame(oldCharacter.PrimaryPart.CFrame)
plr.Character = newCharacter
newCharacter.Parent = workspace
end)
2 Likes
kanapuro
(wanderer)
#3
My mistake, I was under the impression that was needed for the game to identify the player. Apparently not.
2 Likes
Katrist
(Katrist)
#4
It does. .OnServerEvent already identifies the player though.
2 Likes
system
(system)
Closed
#5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.