I’ve been trying to turn the player into slippery ice by pressing a button. For some reason everything I try doesn’t work. My final attempt at making this used a leaderstat for parts of the script (you’ll see once you read the script. Do you guys have any ideas?
leaderstat script (in server script service):
game.Players.PlayerAdded:Connect(function(plr)
local ls = Instance.new("Folder",plr)
ls.Name = "IceCheck"
local ice = Instance.new("BoolValue",ls)
ice.Name = "IceOn"
ice.Value = false
end)
ice button script (starter character scripts)
local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local Debounce = true
local mouseDown = false
-- ANimation---
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animInstance = Instance.new("Animation")
animInstance.AnimationId = "rbxassetid://6715952610" -- Animation
local SlashAnim = humanoid:LoadAnimation(animInstance) -- SlashAnim You Can Change Name
--Sound--
local Player = Game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()
local UserInputService = game:GetService("UserInputService")
local db = false
local Tapped = false
UserInputService.InputBegan:Connect(function(Input, GameStuff)
if GameStuff then return end
if Input.KeyCode == Enum.KeyCode.F or Input.KeyCode == Enum.KeyCode.ButtonL1 then
if Debounce == true then
Debounce = false
--Animation--
SlashAnim:Play() -- Animation Work
----------
game.Players.LocalPlayer.IceCheck.IceOn.Value = true
wait(.2) -- Cooldown
Debounce = true
Debounce = true
end
end
end)
Ice enabler script (starter character scripts)
local ice = game.Players.LocalPlayer.IceCheck.IceOn.Value
Char = script.Parent
local leg = script.Parent.RightLeg
ice:GetPropertyChangedSignal("Value"):connect(function()
if game.Players.LocalPlayer.IceCheck.IceOn.Value == true then
leg.CustomPhysicalProperties = true
leg.CustomPhysicalProperties.Friction = 0
leg.CustomPhysicalProperties.FrictionWeight = 100
leg.CustomPhysicalProperties.Density = 100
leg.CustomPhysicalProperties.Elasticity = 1
elseif game.Players.LocalPlayer.IceCheck.IceOn.Value == false then
end
end)
what do you mean stun yourself? Do you mean sitting? That would be a good idea, but I have a bunch of scripts in the game I’m trying to put this in. One of those scripts makes it so that you can’t really sit down. I’ve tried turning my characters leg into ice while playtesting in studio and it works. I just need to turn their leg into ice through a script
So you’re saying you need a script that can make your character turn into ice when they click a button…? That’s very easy coding I thought you got that set up already.
Easy fix, except you’re going to need a new set of codes, since I am bored I can write one for you.
Make this a local script inside the button:
local humanoidrootpart = game.Players.LocalPlayer.Character.HumanoidRootPart
script.Parent.MouseButton1Click:Connect(function(player)
if humanoidrootpart.Material == Enum.Material.Plastic then
humanoidrootpart.Material = Enum.Material.Ice
elseif humanoidrootpart.Material == Enum.Material.Ice then
humanoidrootpart.Material = Enum.Material.Plastic
end
end)
Hope this helps, You can obv change it and add stuff.
apparently I didn’t know how to use custom physical properties. The entire problem was that I didn’t know how to use custom physical properties in scripts, so I did a quick search and got my problem solved. If you stumble upon this post, here is the solution: BasePart | Roblox Creator Documentation