hello there, In most of all guns they have a "OnKeyDown" function that when you press r that reloads the gun. What i am trying to do is make the guns mag which is a meshpart in side the gun tool, to turn the transparency to 1, that way, when the reload animation plays, the mag transparency would be 1, and when the animation stops the transparency would go back to normal.
How would i type that in this line of code? thanks for help!
function OnKeyDown(key) if string.lower(key) == 'r' then Reload() if RecoilTrack then RecoilTrack:Stop() end end end
this is gonna be alot this assumes mag is one part/ a union first of all keydown or whatever is deprecated do this make sure its a local script
local uis = game:GetService("UserInputService") uis.InputBegan:Connect(function(Input) if Input.Keycode == Enum.Keycode.R then Reload() if RecoilTrack then RecoilTrack:Stop() end end end)
Now add a Remote event to replicated storage Name it SetTransparency
Now go back to the local script and put this code in Idk where your mag is so i will use mag you put the index of the mag
local uis = game:GetService("UserInputService") uis.InputBegan:Connect(function(Input) if Input.Keycode == Enum.Keycode.R then Reload() if RecoilTrack then RecoilTrack:Stop() end game.RepliactedStorage.SetTransparency:FireServer(mag, 1) end end)
now go to server script service add a script then put this script in it
game.RepliactedStorage.SetTransparency.OnServerEvent:Connect(function(plr, object, trans) object.Transparency = trans end)