soo after running the game and checking the output, I can’t find the reason why my mouse decal wont work, sorry in advance i dont know how to make those script box thingy
local tool = script.Parent --Getting the Tool
local player = game:GetService(“Players”).LocalPlayer --Getting the player
local mouse = player:GetMouse() --Getting the mouse
local sound = tool:WaitForChild(“Gunfire”)
local torso = “”
local reloading = false --check if we reloading
local contextActionService = game:GetService(“ContextActionService”) --allow mobile player
local bodytype = nil --check wheter is R6 or R15
local difference = 0 --difference between head and mouse
local replicatedStorage = game:GetService(“ReplicatedStorage”)
local gungui = tool:WaitForChild(“GunGui”)
local bullets = tool:WaitForChild(“Bullets”)
local reloadtime = 2.5
–remote events
local equipAnimation = replicatedStorage:WaitForChild(“EquipAnimation”)
local headshot = replicatedStorage:WaitForChild(“Headshot”)
local reload = replicatedStorage:WaitForChild(“Reload”)
local shootevent = replicatedStorage:WaitForChild(“ShootEvent”)
local unequipanimation = replicatedStorage:WaitForChild(“UnequipAnimation”)
–Remote Function
local checkBodyType = replicatedStorage:WaitForChild(“CheckBodyType”)
local fetchBulletsLeft = replicatedStorage:WaitForChild(“FetchBulletsLeft”)
–find body type
function findBodyType() --use to determine whether a playyer is r6 or r15 (can be done only if we put the function name)
bodytype = checkBodyType:InvokeServer(tool) --Invoking the remote function to check the player is r6 or r15 then send back
print(bodytype) --then print the result
end
–reloading function
function reload()
reloading = true
reload:FireServer(tool.reload)
mouse.Icon = “reloading - Roblox”
player.PlayerGui:WaitForChild(“GunGui”).Bullets.Text = “Reloading…”
wait(reloadtime)
bullets.Value = 6
player.PlayerGui:WaitForChild(“GunGui”).Bullets.Text = "Bullets: "…bullets.Value
mouse.Icon = “guncrosshair - Roblox”
equipAnimation:FireServer(tool.shoot)
reloading = false
end
–when the tool is equipped the following event will run
tool.Equipped:Connect(function(mouse)
gungui:Clone().Parent = player.PlayerGui --we are cloning gun gui to the players screen
findBodyType() --calling the function above to find if r6 or r 15
equipAnimation:FireServer(tool.shoot) --calling the equip animation remoteevent to play the shoot animation
mouse.Icon = (“guncrosshair - Roblox”)
mouse.Button1Down:Connect(function()
if bullets.Value <=0 or reloading == true then
–dont do anything ‘’’
else
local head = game.Workspace[player.Name].Head.CFrame.lookVector – finding players name and where they look
local mouse = CFrame.new(game.Workspace[player.Name].Head.Position,mouse.Hit.p).LookVector
difference = (head-mouse)
local ray = Ray.new(tool.Handle.CFrame.p, (player:GetMouse().Hit.p - tool.Handle.CFrame.p).unit*300)
local part,position = game.Workspace:FindPartOnRay(ray,player.Character,false,true)
sound:Play()
if difference.magnitude < 1.33 then
shootevent:FireServer(tool,position,part)
bullets.Value = bullets.Value - 1
end
end
end)
local reloadMobileButton = contextActionService:BindAction("ReloadBtn",reload,true,"r")
contextActionService:SetPosition("ReloadBtn",UDim2.new(0.72,-25,0.20,-25))
contextActionService:SetImage("ReloadBtn","https://www.roblox.com/library/15076802864/reload")
end)
tool.Unequipped:Connect(function()
mouse.Icon = “”
unequipanimation:FireServer(tool.shoot)
player.PlayerGui.GunGui:Destroy()
contextActionService:UnbindAction(“ReloadBtn”)
end)