**I have a part that appears when I press E in my game. The local script inside of StarterCharacterScripts looks like this: **
local uis = game:GetService("UserInputService")
local enabled = true
uis.InputBegan:Connect(function(key, processed)
if processed == true then return end
if key.KeyCode == Enum.KeyCode.Q then
if enabled then
enabled = false
game.ReplicatedStorage.OnE:FireServer()
wait(10)
enabled = true
end
end
end)
**and the server script looks like this: **
local tweenservice = game:GetService("TweenService")
game.ReplicatedStorage.OnE.OnServerEvent:Connect(function(plr)
plr.Character.Humanoid.WalkSpeed = 0
wait()
plr.Character.HumanoidRootPart.Anchored = true
local anim = Instance.new("Animation", plr.Character)
anim.AnimationId = "rbxassetid://4811155176"
plr.Character.Humanoid:LoadAnimation(anim):Play()
local part = script.Wall:Clone()
part.Parent = workspace
part.CFrame = CFrame.new(plr.Character.HumanoidRootPart.Position + plr.Character.HumanoidRootPart.CFrame.LookVector*10)
part.Orientation = plr.Character.HumanoidRootPart.Orientation
local info = TweenInfo.new(
.5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.InOut,
0,
false,
0
)
local goal = {
Transparency = 0
}
local tween = tweenservice:Create(part, info, goal)
tween:Play()
wait(2)
anim:Destroy()
plr.Character.HumanoidRootPart.Anchored = false
plr.Character.Humanoid.WalkSpeed = 16
wait(2)
local info2 = TweenInfo.new(
3,
Enum.EasingStyle.Linear,
Enum.EasingDirection.InOut,
0,
false,
0
)
local goal2 = {
Transparency = 1
}
local tween2 = tweenservice:Create(part, info2, goal2)
tween2:Play()
wait(3)
part:Destroy()
end)
(it has the part inside)
It all works but I was wondering how I could make it so that you can only press E to make the part appear when you have a tool equipped. Thanks!

1 comment
Make a remote event that enables that?