#How could i make so the item drops to the ground?
1 messages · Page 1 of 1 (latest)
you could just have physics apply to the dropped tool for a second (by unachoring it, then reanchoring it after a few seconds (to save on physics calculations)), yet that could cause some unwanted physics issues
have tried that, if its unachored it just falls through the ground for some reason
That's most likely due to you having set CanCollide to false. You can fix this by either using collisiongroups or just setting it back to true as you drop the weapon
oh ye, forgot that lol, let me try that
how can i check if the player is holding an item
You can just use currentTool
did that
** You are now Level 6! **
Set it to nil if the player drops a weapon (without picking one up), and just the if currentTool when he picks something up
if that check passes, then you know that he has a tool that he first has to drop
okay
(I would also just make a function for dropping tools, and fire it both when the player "drops" the tool, and when he picks a tool up while already having one)
Just makes it easier to write it all
You also need to run it when you switch tools
I would also maybe change over currentTool to an instance instead of a string, will help with processing
okay
i got an error
PlayerScripts.Item:55: Expected identifier when parsing expression, got ')' - Studio - Item:55
show line 55
its line 60
one of your if statements has no end
i tried to add an end, nothing changed
it could also be multiple ones, just format the code and see where you're missing ends
You're most likely still missing one (or have an extra one)
i cant find it tho
send the entire code
ok
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local inputservice = game:GetService('UserInputService')
local tweenService = game:GetService('TweenService')
local player = game.Players.LocalPlayer
local currentTool = nil
local camera = workspace.CurrentCamera
UIS.InputChanged:Connect(function(input)
if mouse.Target then
if mouse.Target:FindFirstChild("Show") then
player.PlayerGui.Info.Enabled = true
player.PlayerGui.Info.Adornee = mouse.Target
player.PlayerGui.Info.Titel.Text = mouse.Target.Name
player.PlayerGui.Info.Disc.Text = mouse.Target.Disc.Text
player.PlayerGui.Info.Pickup.Text = mouse.Target.Pickup.Text
end
end
local info = TweenInfo.new(
0,
Enum.EasingStyle.Linear
)
local debounce = false
inputservice.InputBegan:Connect(function(input, IS)
if IS == true then return end
if input.KeyCode == Enum.KeyCode.E and mouse.Target then
mouse.Target:FindFirstChild("Show").Parent.CanCollide = false
currentTool = mouse.Target.Name
if currentTool then
player.PlayerGui.InGameGUI.ItemCtrl.ItemFull.Visible = true
wait(2)
player.PlayerGui.InGameGUI.ItemCtrl.ItemFull.Visible = false
end
else
while task.wait() do
for _, v in pairs(workspace.Tools:GetDescendants()) do
if v.Name == currentTool then
local targetCFrame = camera.CFrame * CFrame.new(2.5,-1,-2) * CFrame.Angles(math.rad(-90), math.rad(0), 0)
local tween = tweenService:Create(v, info, {CFrame = targetCFrame})
tween:Play()
end
end
end
end```
if input.KeyCode == Enum.KeyCode.G and debounce then
if currentTool then
for _, v in pairs(workspace.Tools:GetDescendants()) do
if v.Name == currentTool then
v:FindFirstChild("Show").Parent.CanCollide = true
v:FindFirstChild("Show").Parent.Anchored = false
currentTool = nil
end
end
end)
else
player.PlayerGui.Info.Enabled = false
player.PlayerGui.Info.Adornee = nil
player.PlayerGui.Info.Titel.Text = ""
player.PlayerGui.Info.Disc.Text = ""
player.PlayerGui.Info.Pickup.Text = ""
end)```
line 10/29 don't close in time
basically, there is no "end" after it
okay
where should there be an end in that place
it just gives me more errors when i add one
@queen spruce
... I'll be nice and redownload studio to help you, don't have any proper IDE set up for lua(u) right now.
I'll get back to you later
alright, thank you
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local inputservice = game:GetService('UserInputService')
local tweenService = game:GetService('TweenService')
local player = game.Players.LocalPlayer
local currentTool = nil
local camera = workspace.CurrentCamera
local debounce = false
UIS.InputChanged:Connect(function(input)
if mouse.Target then
if mouse.Target:FindFirstChild("Show") then
player.PlayerGui.Info.Enabled = true
player.PlayerGui.Info.Adornee = mouse.Target
player.PlayerGui.Info.Titel.Text = mouse.Target.Name
player.PlayerGui.Info.Disc.Text = mouse.Target.Disc.Text
player.PlayerGui.Info.Pickup.Text = mouse.Target.Pickup.Text
end
end
end)
local info = TweenInfo.new(
0,
Enum.EasingStyle.Linear
)
inputservice.InputBegan:Connect(function(input, IS)
if IS == true then return end
if input.KeyCode == Enum.KeyCode.E and mouse.Target then
mouse.Target:FindFirstChild("Show").Parent.CanCollide = false
currentTool = mouse.Target.Name
if currentTool then
player.PlayerGui.InGameGUI.ItemCtrl.ItemFull.Visible = true
wait(2)
player.PlayerGui.InGameGUI.ItemCtrl.ItemFull.Visible = false
end
else
while task.wait() do
for _, v in pairs(workspace.Tools:GetDescendants()) do
if v.Name == currentTool then
local targetCFrame = camera.CFrame * CFrame.new(2.5,-1,-2) * CFrame.Angles(math.rad(-90), math.rad(0), 0)
local tween = tweenService:Create(v, info, {CFrame = targetCFrame})
tween:Play()
end
end
end
end
if input.KeyCode == Enum.KeyCode.G and debounce then
if currentTool then
for _, v in pairs(workspace.Tools:GetDescendants()) do
if v.Name == currentTool then
v:FindFirstChild("Show").Parent.CanCollide = true
v:FindFirstChild("Show").Parent.Anchored = false
currentTool = nil
end
end
else --I'm not even sure what this else belongs to.. You'll probably have to move this around, this is why guard clauses are an import life skill
player.PlayerGui.Info.Enabled = false
player.PlayerGui.Info.Adornee = nil
player.PlayerGui.Info.Titel.Text = ""
player.PlayerGui.Info.Disc.Text = ""
player.PlayerGui.Info.Pickup.Text = ""
end
end
end)
@crude orbit , just make sure to read that comment
ye
i did
ty
the error is gone now, but nothing is happening when i press g
is it because of the tween?
that was for line 19, i dont know how it ended up all the way down there lol, it didint cause any problems before so i just didnt bother to fix it
I simple added "ends" where it seemed logical, it can very well be that some ends are place in the wrong position
As stated in the comment, this is why guardclauses are important, as I've no clue which else belongs to which if
.
@queen spruce