Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Had a question about my "Placables" system breaking another script when a new item is placed?

Asked by 2 years ago

PlacablesClient: Located inside of the "HammerToolGui" basic rundown is that this script waits for a player to click a button in the gui the corresponds to what item there trying to place. The script gets the model (and its parts) and creates a clone to provide the player with a visual on where there newly placed item will be. The script looks for the mouse position and other important stuff like that and sends it off to the server as soon as the player releases their left mouse button. The server receives this info and places the actual item accordingly. There's also a rotate function inside of this script but I don't think that's causing my problem so i wont go into detail. (I know its poorly written but I'm brand new)

001local PlaceEvent = game.ReplicatedStorage.PlaceableEvents.PlaceEvent
002local ObjectFolder = game.ReplicatedStorage:WaitForChild("PlaceableStorage")
003 
004local Player = game.Players.LocalPlayer
005local Character = Player.Character or Player.CharacterAdded:Wait()
006local HumanoidrootPart = Character:WaitForChild("HumanoidRootPart")
007local Mouse = Player:GetMouse()
008 
009local Frame = script.Parent.ItemList
010local UIS = game:GetService("UserInputService")
011local RunService = game:GetService("RunService")
012local GUI = game.StarterGui.HammerToolGui.MainFrame
013 
014local PlacingObject = false
015local RotatingObject = false
View all 129 lines...

PickupManager: Located inside of "StarterPlayerScripts" basic rundown this script works in conjunction with another system (completely separate from placables system) my inventory system. The script waits for a player to get close enough to the item on the ground and then displays a gui based on that. The script then listens for the player to press the G key to "collect" the item.

01local function onInputEnded(input, mouse, player, pickupItemEvent)
02    if input.KeyCode == Enum.KeyCode.G then
03        local target = mouse.Target
04        if target and target:FindFirstChild("Pickable") then
05            local item = target
06            local distanceFromItem = player:DistanceFromCharacter(item.Position)
07            if distanceFromItem < 7 then
08                print(item.Name)
09                print(item.Desc.Value)
10                pickupItemEvent:FireServer(item.Name, item.Desc.Value)
11                print("fired to server")
12                item:Destroy()
13            end
14        end
15    end
View all 47 lines...

So now that you have all of that information I can tell you about the actual problem. When I join the game and place one of the "placables" the game will no longer allow me to pick up items, the gui to pick things up wont even display (keep in mind these to scripts do not work in conjunction with each other in any way). What's strange is if the player dies they can pick up items again but again after a "placable" is placed the player can no longer pick up items.

Anyone have any ideas?

0
This is dizzy land :O T3_MasterGamer 2189 — 2y
0
and your name is MasterGamer? I'm just asking a question, if you don't have an answer keep your mouth shut ;) KCbiulder 0 — 2y

Answer this question