N_aps
(N_aps)
April 2, 2023, 5:34pm
1
So I am trying to make a script where when the player clicks the button E on their keyboard their character grows by 1.5, for some reason when you click E nothing happens, this script was working 2 years ago when I was making this game but now it doesnt, can someone help?
local plr = game.Players.LocalPlayer
UserInputService = game:GetService("UserInputService")
local ePressed = false
UserInputService.InputBegan:Connect(function(input, gameProccosedEvent)
if input.KeyCode == Enum.KeyCode.E then
ePressed = true
if ePressed then
plr.Character.Humanoid.HeadScale.Value = 1.5
plr.Character.Humanoid.BodyDepthScale.Value = 1.5
plr.Character.Humanoid.BodyHeightScale.Value = 1.5
plr.Character.Humanoid.BodyWidthScale.Value = 1.5
plr.Character.Humanoid.WalkSpeed = 25
end
end
end)
2 Likes
I suggest handling it to the server. Create a remote event, fire it to the server and let the server change the Character Size. Your stuff works only client sided ( only you can see the changes )
1 Like
You would need to set the properties on the server.
Other issues
= 1.5
Did you mean *= 1.5
?
UserInputService = game:GetService(âUserInputServiceâ)
Use local
ePressed = true
if ePressed then
Useless variable
gameProccosedEvent
Incorrect spelling
plr.Character.Humanoid.
plr.Character.Humanoid.
plr.Character.Humanoid.
plr.Character.Humanoid.
plr.Character.Humanoid.
Please use variables.
1 Like
The gameProcessedEvent prevents firing the function when youâre chatting, he should implement it.
N_aps
(N_aps)
April 2, 2023, 5:41pm
5
its a singleplayer game btw, does that effect any of this? also its a local script
N_aps
(N_aps)
April 2, 2023, 5:42pm
6
the game is singleplayer so that doesnt matter right
Not sure about that, I recommend trying letting the server handling it.
And read what Rick said, it might fix your issue
N_aps
(N_aps)
April 2, 2023, 5:49pm
9
it didnt idk why tho nothing is working
N_aps
(N_aps)
April 2, 2023, 5:55pm
10
that didnt fix it idk why, my script seems to be good
N_aps
(N_aps)
April 2, 2023, 6:08pm
11
I found the problem, the value of the character size is changing but not the character size
In pretty sure you should try to do it on the server? I think itâs because the server handles it that stuff, so if your doing it on the client it wonât replicate to the server
N_aps
(N_aps)
April 2, 2023, 6:21pm
13
I did it on the server heres my script, for some reason when you press E you grow but when you press q you dont shrink
local remoteEvent1 = game.ReplicatedStorage.ePress
local remoteEvent2 = game.ReplicatedStorage.qPress
remoteEvent1.OnServerEvent:Connect(function(player, ePressed)
if ePressed then
player.Character.Humanoid.HeadScale.Value = 1.5
player.Character.Humanoid.BodyDepthScale.Value = 1.5
player.Character.Humanoid.BodyHeightScale.Value = 1.5
player.Character.Humanoid.BodyWidthScale.Value = 1.5
player.Character.Humanoid.WalkSpeed = 25
else
player.Character.Humanoid.HeadScale.Value = 1
player.Character.Humanoid.BodyDepthScale.Value = 1
player.Character.Humanoid.BodyHeightScale.Value = 1
player.Character.Humanoid.BodyWidthScale.Value = 1
player.Character.Humanoid.WalkSpeed = 16
end
end)
remoteEvent2.OnServerEvent:Connect(function(player, qPressed)
if qPressed then
player.Character.Humanoid.HeadScale.Value = 0.5
player.Character.Humanoid.BodyDepthScale.Value = 0.5
player.Character.Humanoid.BodyHeightScale.Value = 0.5
player.Character.Humanoid.BodyWidthScale.Value = 10.5
player.Character.Humanoid.WalkSpeed = 18
else
player.Character.Humanoid.HeadScale.Value = 1
player.Character.Humanoid.BodyDepthScale.Value = 1
player.Character.Humanoid.BodyHeightScale.Value = 1
player.Character.Humanoid.BodyWidthScale.Value = 1
player.Character.Humanoid.WalkSpeed = 16
end
end)
local UserInputService = game:GetService("UserInputService")
local remoteEvent = game.ReplicatedStorage.ePress
local ePressed = false
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
ePressed = true
remoteEvent:FireServer(ePressed)
end
end)
VSCPlays
(Void)
April 2, 2023, 6:37pm
14
The character size isnât changing because you didnât put *=
, I fixed the scripts for you
--// Client //--
local UserInputService = game:GetService("UserInputService")
local remoteEvent = game.ReplicatedStorage.ePress
UserInputService.InputBegan:Connect(function(input)
local ePressed = input.KeyCode == Enum.KeyCode.E
if ePressed then
remoteEvent:FireServer(ePressed)
end
end)
--// Server //--
local RepStorage = game:GetService("ReplicatedStorage")
local remoteEvent1 = RepStorage:WaitForChild("ePress")
local remoteEvent2 = RepStorage:WaitForChild("qPress")
remoteEvent1.OnServerEvent:Connect(function(player, ePressed)
local Humanoid = player.Character:WaitForChild("Humanoid")
if ePressed then
Humanoid.HeadScale.Value *= 1.5
Humanoid.BodyDepthScale.Value *= 1.5
Humanoid.BodyHeightScale.Value *= 1.5
Humanoid.BodyWidthScale.Value *= 1.5
Humanoid.WalkSpeed = 25
else
Humanoid.HeadScale.Value *= 1
Humanoid.BodyDepthScale.Value *= 1
Humanoid.BodyHeightScale.Value *= 1
Humanoid.BodyWidthScale.Value *= 1
Humanoid.WalkSpeed = 16
end
end)
remoteEvent2.OnServerEvent:Connect(function(player, qPressed)
local Humanoid = player.Character:WaitForChild("Humanoid")
if qPressed then
Humanoid.HeadScale.Value *= 0.5
Humanoid.BodyDepthScale.Value *= 0.5
Humanoid.BodyHeightScale.Value *= 0.5
Humanoid.BodyWidthScale.Value *= 0.5
Humanoid.WalkSpeed = 18
else
Humanoid.HeadScale.Value *= 1
Humanoid.BodyDepthScale.Value *= 1
Humanoid.BodyHeightScale.Value *= 1
Humanoid.BodyWidthScale.Value *= 1
Humanoid.WalkSpeed = 16
end
end)
1 Like
N_aps
(N_aps)
April 2, 2023, 6:53pm
15
with this script when you press E you shrink and q doe snothing
VSCPlays
(Void)
April 2, 2023, 6:58pm
16
you used the code incorrectly, did you put qPress or ePress?
N_aps
(N_aps)
April 2, 2023, 7:20pm
17
local RepStorage = game:GetService(âReplicatedStorageâ)
local remoteEvent1 = RepStorage:WaitForChild(âePressâ)
local remoteEvent2 = RepStorage:WaitForChild(âqPressâ)
remoteEvent1.OnServerEvent:Connect(function(player, ePressed)
local Humanoid = player.Character:WaitForChild(âHumanoidâ)
if ePressed then
Humanoid.HeadScale.Value *= 1.5
Humanoid.BodyDepthScale.Value *= 1.5
Humanoid.BodyHeightScale.Value *= 1.5
Humanoid.BodyWidthScale.Value *= 1.5
Humanoid.WalkSpeed = 25
else
Humanoid.HeadScale.Value *= 1
Humanoid.BodyDepthScale.Value *= 1
Humanoid.BodyHeightScale.Value *= 1
Humanoid.BodyWidthScale.Value *= 1
Humanoid.WalkSpeed = 16
end
end)
and
local RepStorage = game:GetService(âReplicatedStorageâ)
local remoteEvent2 = RepStorage:WaitForChild(âqPressâ)
remoteEvent2.OnServerEvent:Connect(function(player, qPressed)
local Humanoid = player.Character:WaitForChild(âHumanoidâ)
if qPressed then
Humanoid.HeadScale.Value *= 0.5
Humanoid.BodyDepthScale.Value *= 0.5
Humanoid.BodyHeightScale.Value *= 0.5
Humanoid.BodyWidthScale.Value *= 0.5
Humanoid.WalkSpeed = 18
else
Humanoid.HeadScale.Value *= 1
Humanoid.BodyDepthScale.Value *= 1
Humanoid.BodyHeightScale.Value *= 1
Humanoid.BodyWidthScale.Value *= 1
Humanoid.WalkSpeed = 16
end
end)
for q press
VSCPlays
(Void)
April 2, 2023, 7:21pm
18
please put three backticks (```) for the code, like this
```lua
-- put some code here
```
and the result is:
-- put some code here
N_aps
(N_aps)
April 2, 2023, 7:25pm
19
local RepStorage = game:GetService(âReplicatedStorageâ)
local remoteEvent1 = RepStorage:WaitForChild(âePressâ)
local remoteEvent2 = RepStorage:WaitForChild(âqPressâ)
remoteEvent1.OnServerEvent:Connect(function(player, ePressed)
local Humanoid = player.Character:WaitForChild(âHumanoidâ)
if ePressed then
Humanoid.HeadScale.Value *= 1.5
Humanoid.BodyDepthScale.Value *= 1.5
Humanoid.BodyHeightScale.Value *= 1.5
Humanoid.BodyWidthScale.Value *= 1.5
Humanoid.WalkSpeed = 25
else
Humanoid.HeadScale.Value *= 1
Humanoid.BodyDepthScale.Value *= 1
Humanoid.BodyHeightScale.Value *= 1
Humanoid.BodyWidthScale.Value *= 1
Humanoid.WalkSpeed = 16
end
end)
and for q
local RepStorage = game:GetService(âReplicatedStorageâ)
local remoteEvent2 = RepStorage:WaitForChild(âqPressâ)
remoteEvent2.OnServerEvent:Connect(function(player, qPressed)
local Humanoid = player.Character:WaitForChild(âHumanoidâ)
if qPressed then
Humanoid.HeadScale.Value *= 0.5
Humanoid.BodyDepthScale.Value *= 0.5
Humanoid.BodyHeightScale.Value *= 0.5
Humanoid.BodyWidthScale.Value *= 0.5
Humanoid.WalkSpeed = 18
else
Humanoid.HeadScale.Value *= 1
Humanoid.BodyDepthScale.Value *= 1
Humanoid.BodyHeightScale.Value *= 1
Humanoid.BodyWidthScale.Value *= 1
Humanoid.WalkSpeed = 16
end
end)
for q press