How To Make A Part Appear On A Player

Hello! I need help on making a block appear on a player with a ;freeze chat command. I have the command down and it freeze’s you, but I want a block to appear on you. This script is in serverscriptservice.
Thanks!

here is The main part I need help on

                    local Ice = workspace.Ice
		Ice.CFrame = Player.Character.HumanoidRootPart.CFrame + Vector3.new(5,13,5) 

here is the whole script
–// Services \–
local Players = game:GetService(“Players”)

–// Settings \–
local Prefix = ‘;’

local Admins = {
[‘AmphibionPlayzDev’] = ‘Admin’;
}

–// Functions \–
local function CheckForTarget(Target)
if not Target then
warn(‘Target is not valid’)
return false
else
print(‘Target is valid’)
return true
end
end
Players.PlayerAdded:Connect(function(Player)
if Admins[Player.Name] then
print(‘Admin’…Player.Name…’ has joined the game freeze’)
Player.Chatted:Connect(function(Msg)
if Msg:sub(1,8) == Prefix…'freeze ’ or Msg:sub(1,8) == Prefix…'Freeze ’ then

			local PlayerName = Msg:sub(9)
			local Target = nil		

			if PlayerName == "me" or "Me" then
				Target = Player				
			else	
				Target = Players:FindFirstChild(PlayerName)
			end
			
			local Ice = workspace.Ice
			local Valid = CheckForTarget(Target)
			
			if Valid then				
				
				local remwalk = Target.Character.Humanoid.WalkSpeed
				local remjump = Target.Character.Humanoid.JumpPower
				
				Ice.CFrame = Player.Character.HumanoidRootPart.CFrame + Vector3.new(5,13,5) 
				
				Target.Character.Humanoid.WalkSpeed = 0
				Target.Character.Humanoid.JumpPower = 0
				wait(15)
				Target.Character.Humanoid.WalkSpeed = remwalk
				Target.Character.Humanoid.JumpPower = remjump 
			end
		end
	end)		
end

end)

Change this to Ice.CFrame = Target.Character...

1 Like

Why are you adding the Y Size so much to the CFrame? Wouldn’t it be easier to just set it as it is without adding anything?

I’d also recommend cloning the Ice variable inside ReplicatedStorage if you wanted to freeze more than 1 player

1 Like

so @ Jackscarlett if i add it to the replicated storage what would it be instead of workspace.Ice?

It’d be something relevant to this:

–// Services \–
local Players = game:GetService(“Players”)

–// Settings \–
local Prefix = ‘;’

local Admins = {
[‘AmphibionPlayzDev’] = ‘Admin’;
}

–// Functions \–
local function CheckForTarget(Target)
if not Target then
warn(‘Target is not valid’)
return false
else
print(‘Target is valid’)
return true
end
end
Players.PlayerAdded:Connect(function(Player)
if Admins[Player.Name] then
print(‘Admin’…Player.Name…’ has joined the game freeze’)
Player.Chatted:Connect(function(Msg)
if Msg:sub(1,8) == Prefix…'freeze ’ or Msg:sub(1,8) == Prefix…'Freeze ’ then

			local PlayerName = Msg:sub(9)
			local Target = nil		

			if PlayerName == "me" or "Me" then
				Target = Player				
			else	
				Target = Players:FindFirstChild(PlayerName)
			end
			
			local IceClone = game.ReplicatedStorage.Ice:Clone()
            IceClone.Parent = workspace
			local Valid = CheckForTarget(Target)
			
			if Valid then				
				
				local remwalk = Target.Character.Humanoid.WalkSpeed
				local remjump = Target.Character.Humanoid.JumpPower
				
				IceClone.CFrame = Target.Character.HumanoidRootPart.CFrame
				
				Target.Character.Humanoid.WalkSpeed = 0
				Target.Character.Humanoid.JumpPower = 0
				wait(15)
				Target.Character.Humanoid.WalkSpeed = remwalk
				Target.Character.Humanoid.JumpPower = remjump 
			end
		end
	end)		
end
end)

Just make sure to put the Ice part inside ReplicatedStorage

1 Like
local Ice = game.ReplicatedStorage.Ice:Clone()
Ice.Parent = game.Workspace
Ice.CFrame = --What We just fixed
2 Likes

thanks so much guys for all the help! :smile:

2 Likes