im not a scripter but i’ll try to explain, I’m using a simple gun engine which works fine but when i die in game the system doesen’t work anymore, is there some sort of check script i can add which reloads or makes sure everything works every time you spawn?
Where is the script located? how do you give the player the gun? is the script still added into the player after respawn? did you use when player join instead of on respawn (or whatever its called)
the scripts are all in the tool itself
where is the tool located? and is there a serverside script for the gun?
the tools are only in the starterpack, there is no serverside script for the tools
wdym by the tool doens’t work the second time? like, does it not shoot? does it not appear? does it shoot but deal no dmg?
after you die when you equip the tool your just holding the handle, you cant shoot and the animations dont play. Basicly just turns it into a handle and none of the scripts activate
weird, send ss of the tool in workspace ig
Do you have any scripts with RunContext
? If so, make sure they are disabled while the tool is present in the starter pack. Do you have any scripts outside of the tool?
Here is the script:
local Player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
local weapon = mouse.Target
local function onKeyDown(key)
if key == “e” then
local bullet = Instance.new(“Part”)
bullet.BrickColor = BrickColor.new(“Really black”)
bullet.Material = Enum.Material.SmoothPlastic
bullet.Anchored = true
bullet.CanCollide = true
bullet.Locked = true
bullet.Size = Vector3.new(0.3, 0.3, 2)
bullet.CFrame = CFrame.new(weapon.Position, mouse.Hit.p)
bullet.Parent = game.Workspace
bullet.Touched:connect(function(hit)
local bodyPosition = CFrame.new(bullet.Position)
bullet:Destroy()
for i,v in pairs(hit.Parent:GetChildren()) do
if v:IsA(“Humanoid”) then
v.Health = v.Health - math.random(1, 50)
end
end
end)
end
end
mouse.Button1Down:connect(function()
onKeyDown(“e”)
end)
You can use the Player
’s CharacterAdded
event to run this script again.
local Player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
local function onKeyDown(key)
if key == “e” then
local weapon = mouse.Target
local bullet = Instance.new(“Part”)
bullet.BrickColor = BrickColor.new(“Really black”)
bullet.Material = Enum.Material.SmoothPlastic
bullet.Anchored = true
bullet.CanCollide = true
bullet.Locked = true
bullet.Size = Vector3.new(0.3, 0.3, 2)
bullet.CFrame = CFrame.new(weapon.Position, mouse.Hit.p)
Your phone formatted the quotation marks in such a way that they cannot be parsed.
I have added tabs though I write this is Studio.