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

How would i get a tool to on click summon a entity clone where the mouse clicked?

Asked by 5 years ago
Edited 5 years ago

i have tried to do this for about a day or two but nothing i have works and mind you i used the code on the intro to player tools where they make the wand to help me understand this and when i use its code the "clickEvent" is not a valid part of "tool" i have edited the local clickEvent = tool.clickEvent to local clickEvent = tool.activated but then i found out that the fireserver script in the wand roblox made was no longer work i am a nub when coding and was thinking somebody here would help me understand how to do this oh heres the scripts th sed that wouldn't work for me so i can get a good idea of what to do

 -   -- Local Script
 -   local tool =  script.Parent
 -   local player =  game.Players.LocalPlayer
 -   local mouse = player:GetMouse()
 -   local clickEvent = tool.ClickEvent

-   local  function onActivate()
-     local clickLocation = mouse.Hit
-    clickEvent:FireServer(clickLocation)
-   end

-   tool.Activated:connect(onActivate)
-   tool.Activated:connect(onActivate)
- -   -- Server Script
-   local tool =  script.Parent
-   local clickEvent = tool.ClickEvent
-   local clickEventConnection

-   local  function createPart(location)
-     local part =  Instance.new("Part")
-    part.CFrame  = location
-    part.Parent =  workspace
-   end

-   local  function onClick(player, clickLocation)
-    createPart(clickLocation)
-   end

-   local  function onEquip()
-    clickEventConnection = clickEvent.OnServerEvent:connect(onClick)
-   end

-   local  function onUnequip()
-    clickEventConnection:disconnect()
-   end

-   tool.Equipped:connect(onEquip)
-   tool.Unequipped:connect(onUnequip)
  • please note that this is what im trying to do rather a basic idea of what im doing i dont have any actual scripts made by me to do what im trying to do of which what im trying to do is onClick clone game.ReplicatedStorage.Noob oh btw after this post i tried moving the server script over to server script storage (i think thats what it is) and i still had no luck even with my tiny edits.
0
Oh btw Sorry if i did something wrong while asking the question im just realy desprate cause i dont understand anything yet brushbuggy112 0 — 5y
0
You're code isn't currently very readable, try putting it into a Lua formatter, and then posting it. You'll also probably have to indent every line one extra time. davidgingerich 603 — 5y
0
okay ty ill be doin that brushbuggy112 0 — 5y
0
My little edits where saying that the click event was tool.activated and a couple extra things but i still get errors like Activated isnt part of the server script and i think that if i can figur out what service to use other than the click event thing i could get it to work btw the game im making is a remake of noob crushing tycoon just incase that help you understand what im doin brushbuggy112 0 — 5y

Answer this question