Log in to vote

Why is my Model Placer script working only in ROBLOX Studio and not in game?

Asked by 4 years ago

I am currently wondering why is a LocalScript working perfectly in Studio, but does nothing in the game itself.

The LocalScript itself:

lp = script.Parent
local debounce = false

function onButton1Down(mouse)

if not debounce then
    debounce = true
    local grenade = game.ServerStorage:WaitForChild("Grenade")
    local model = grenade:clone()
    model.Parent = game.Workspace
    model = game.Workspace:WaitForChild("Grenade")
    model.PrimaryPart = model.Union
    local cframe = model.PrimaryPart.CFrame
    model:SetPrimaryPartCFrame(cframe * CFrame.fromEulerAnglesXYZ(math.random(0,359), math.random(0,359), math.random(0,359)))
    debounce = false

function onEquipped(mouse)
    mouse.Button1Down:connect(function() onButton1Down(mouse) end)


The Script is in a Tool and it is supposed to clone a Model called Grenade from ServerStorage to Workspace where the mouse cursor is.

It works without any problems in ROBLOX Studio. However, when I join the game and use the Tool, it does nothing when I click.

As you can see, it is a LocalScript and there is WaitForChild here. It still works perfectly in ROBLOX Studio, but not in the game.

I kindly request your help and advice, fellow scripters.


I'd like to know if its FE or Non-fe or Experimental Mode on Omega_bs 40 — 4y
Non-FE MatiWielun 35 — 4y

1 answer

Log in to vote
Answered by 4 years ago
Edited 4 years ago

It being Fe or Non-FE aside i have made a Non-FE Demo that can be Edited and Researched thru

So what i've done is Placed the Grenade Model into game:GetService("ReplicatedStorage")

I don't know why it worked that time but its probably because i didn't mind to change it

And since its a Local Script we can indeed use :GetMouse()

local Player_Variable_Name_Here = game:GetService("Players").LocalPlayer:GetMouse() to be Exact

and Use Mouse.Button1Down:connect(function() end) instead

The game works online and in studio probably because its non-fe but heres the Tools API and help for making a FE game with Tools

Tool API

Test Game (Open Source)

So what steps should be done to make this script work? MatiWielun 35 — 4y
Use LocalPlayer:GetMouse() for Mouse instead of the Mouse you get from Equipped Event. Omega_bs 40 — 4y

Answer this question